MONZXER is a text-based cave exploration game in the tradition of Hunt the Wumpus, where the player navigates a procedurally generated dodecahedral-style cave network spread across five levels of 20 rooms each, hunting monsters called Monzxers while avoiding spiders, bats, and pits. The cave graph is constructed at lines 399–510 using a randomised adjacency array R(3,101), giving each room three tunnel connections, with hazard positions stored in separate arrays for enemies, spiders, bats, and pits. Player actions include moving between rooms or firing arrows at Monzxers (Z) or Spiders (D), with a limited supply of six arrows tracked by S1. The title screen uses nested PLOT/UNPLOT loops to draw a pixel-art monster graphic before entering SLOW mode for the game, and the SAVE command at line 3580 uses an inverse-video character in the filename as an auto-run flag.
Program Analysis
Program Structure
The program divides into several distinct phases:
- Title/Graphics (lines 1–393): Draws a pixel-art Monzxer sprite using
PLOT/UNPLOTloops, prints the title, entersSLOWmode, then pauses. - Cave Generation (lines 398–510): Allocates and populates the room adjacency array
R(3,101)with bidirectional tunnel connections across 100 rooms. - Game Initialisation (lines 525–960): Places hazards (Monzxers in
W, spiders inS, bats inB, pits inP), builds encounter hint arraysT,C,Q, and the Monzxer adjacency indexX. - Main Game Loop (lines 1000–2290): Describes the current room, reports hazard warnings, handles movement and shooting.
- End Sequences (lines 2990–3170): Win/lose screens, play-again prompt, optional re-use of tunnel set.
- Spider-death Subroutine (lines 3500–3560): Prints an ASCII-art dead spider.
Cave Graph Construction
Lines 399–510 build a bidirectional adjacency structure in R(3,101). Each room (index 1–100) gets three neighbours. The algorithm iterates rooms in groups of five within four bands of 20 (via L=0 TO 80 STEP 20), randomly picking a target room G and checking that the reverse link slot is free before writing both directions. The check at line 437 prevents duplicate edges within the same group-of-five, and line 445 prevents assigning the same back-link twice. This is a constrained random graph rather than a true dodecahedron, but it produces a connected-enough cave for gameplay.
Level System
One hundred rooms are logically divided into five levels of 20 rooms each. YL (lines 1010–1015) is derived from YR by integer division. Room numbers are always displayed relative to the level base (YR-(YL-1)*20), so the player sees rooms 1–20 on every level. Tunnels stored in R use absolute room numbers, and (YL-1)*20 offsets are applied when printing tunnel destinations (line 1560) and when accepting movement input (line 1720). Falling into a pit on levels 1–4 drops the player to the next level down by adding 20 to YR (line 1500); on level 5 it is instantly fatal (line 1520).
Hazard Arrays
| Array | Size | Contents |
|---|---|---|
W(3) | 3 | Monzxer locations (absolute room numbers) |
S(10) | 10 | Spider room indices (into R) |
B(10) | 10 | Bat room indices |
P(10) | 10 | Pit room indices |
T(30) | 30 | Rooms adjacent to spiders (cobweb hint) |
C(30) | 30 | Rooms adjacent to bats |
Q(30) | 30 | Rooms adjacent to pits (draft hint) |
X(36) | 36 | Rooms near Monzxers (smell hint, two hops) |
The X array (lines 870–960) is built in two passes: first the three rooms directly adjacent to each Monzxer, then the nine rooms one step further out, giving a two-hop smell radius. Monzxers that have been killed are marked with room number 101 (an out-of-range sentinel) rather than being removed from the arrays.
Shooting Mechanic
When the player chooses to shoot (line 1630), they input a path of up to 5 rooms (stored in A(2)–A(6); A(1) is the current room). At each step (lines 2140–2160), if the nominated room is not a valid tunnel from the previous room, the arrow is redirected to a random neighbour (lines 2165–2170). The arrow kills whichever target type matches the mode (S$="Z" for Monzxer, S$="D" for Spider). Shooting yourself (arrow path loops back to YR) triggers instant death at line 2240. The arrow supply S1 starts at 6 and decrements each shot; reaching zero ends the game.
Key BASIC Idioms and Techniques
- The
PAUSE 900/INKEY$pattern at lines 1600–1640 and 2012–2017 implements key-wait loops without halting execution, consistent with ZX81/TS1000 practice. SLOW/FASTmode switching at lines 395, 398, 1005, and 3135–3165 controls display stability around intensive operations.- Line 3060 branches to non-existent line 3020, which causes the interpreter to resume at line 3030 — a deliberate technique to re-enter the INKEY$ poll loop.
- The variable name
ENDis used as a flag (lines 5, 396, 3160) to signal whether the end-game graphic loop should stop — it is not a reserved keyword in this dialect. - The title graphic is re-entered via
GOTO 70at line 3170 after a loss, creating an attract-mode loop without redrawing the full screen.
ASCII / Block-Graphic Art
The in-game spider and dead-spider images (lines 1423–1428 and 3500–3560) use block graphic characters and standard punctuation to render multi-row ASCII art directly in PRINT AT statements. The dead spider subroutine at line 3500 is shared between the shooting-a-spider path (line 2036) and the spider-kill-on-move path (line 2217).
Bugs and Anomalies
- Line 2020 / 2030:
NEXT Iat line 2020 is only reached if the spider check loop completes without a match (no spider in current room at shoot time), but theGOTO 2060at line 2030 is unreachable because lines 2011–2017 loop indefinitely waiting for a valid keypress before falling through — the spider-check loop body overwrites the flow with an unconditional wait starting at line 2011. - Line 2195: The spider-arrow check reads
IF YR=S(I)rather thanIF A(I)=S(J)or similar, comparing the player’s room against a spider-room index rather than comparing the arrow’s current path node, likely a logic error that makes the spider-arrow kill nearly non-functional. - Line 1295: After killing a Monzxer in the player’s room, the code sets
W(I)=101and then doesGOTO 870(re-initialise hazard display arrays), butIis the outer loop variable from line 1240; this is valid as long asI≤3, which the guard at line 1295 enforces. - Line 1026: If
YR>99after level adjustment,YRis set toINT(RND*100)-1, which can produce 0 or negative values — an edge-case bug for very high room numbers.
Content
Source Code
1 REM "MONZXER"
2 RAND
5 LET END=0
50 PRINT AT 10,20;"SUPER"
60 PRINT AT 12,18;"MONZXER"
70 FOR I=3 TO 37
80 FOR J=11 TO 19
87 UNPLOT 9,16
90 PLOT J,I
100 NEXT J
110 NEXT I
120 FOR I=16 TO 24
130 FOR J=8 TO 22
140 PLOT J,I
150 NEXT J
160 NEXT I
170 FOR I=22 TO 32
180 PLOT 6,I
190 PLOT 24,I
200 NEXT I
210 PLOT 5,22
220 PLOT 7,22
225 PLOT 7,21
230 PLOT 23,22
235 PLOT 25,22
240 PLOT 23,24
245 PLOT 25,21
250 PLOT 9,35
255 PLOT 10,35
265 PLOT 10,36
270 PLOT 20,36
275 PLOT 20,35
280 PLOT 21,35
285 FOR I=14 TO 16
290 FOR J=3 TO 16
295 UNPLOT I,J
300 NEXT J
305 NEXT I
307 PLOT 23,33
312 PLOT 7,33
315 PLOT 7,32
320 FOR I=5 TO 25
325 IF I=14 THEN LET I=17
330 PLOT I,3
335 NEXT I
338 FOR I=6 TO 24
340 IF I=14 THEN LET I=17
342 PLOT I,4
345 NEXT I
350 PRINT AT 21,3;""" """
352 PRINT AT 21,9;""" """
355 PRINT AT 7,5;"Q"
357 PRINT AT 7,9;"Q"
360 PRINT AT 9,5;" "
365 PRINT AT 5,22;" ----/"
370 PRINT AT 4,28;"/"
375 PRINT AT 3,29;"/"
380 PRINT AT 2,30;"/"
382 UNPLOT 8,17
385 UNPLOT 8,16
387 UNPLOT 9,16
390 UNPLOT 21,16
392 UNPLOT 22,16
393 UNPLOT 22,17
395 SLOW
396 IF END=1 THEN STOP
397 PAUSE 600
398 FAST
399 DIM R(3,101)
400 DIM A(6)
401 FOR I=1 TO 3
402 FOR J=1 TO 101
403 LET R(I,J)=INT (RND*100)+1
404 NEXT J
405 NEXT I
406 LET SW=0
407 LET DM=0
408 FOR L=0 TO 80 STEP 20
410 FOR I=1 TO 20
415 LET K=L+I
420 FOR J=1 TO 3
422 LET J1=J
425 IF J1<INT ((I-1)/5) THEN LET J1=J1-1
430 IF R(J,K)>0 THEN GOTO 495
435 LET G=INT (RND*5)+J1*5+L+1
436 FOR M=1 TO 5
437 IF R(J,L+M+INT ((I-1)/5)*5)=G THEN GOTO 435
438 NEXT M
440 FOR H=1 TO 3
445 IF R(H,G)=K THEN GOTO 435
450 IF R(H,G)=0 THEN GOTO 465
455 NEXT H
460 GOTO 435
465 LET R(J,K)=G
490 LET R(H,G)=K
495 NEXT J
500 NEXT I
510 NEXT L
525 LET YR=INT (RND*20)+1
535 LET S1=6
610 DIM X(36)
620 DIM T(30)
630 DIM C(30)
640 DIM Q(30)
650 DIM W(3)
660 DIM S(10)
670 DIM B(10)
680 DIM P(10)
690 LET DM=0
695 LET SW=0
700 LET SR=INT (RND*100)+1
710 FOR I=1 TO 3
720 LET W(I)=INT (RND*100)+1
725 IF W(I)=YR THEN GOTO 720
730 NEXT I
740 FOR I=1 TO 9 STEP 2
745 FOR J=0 TO 1
750 LET S(I+J)=(INT (RND*20)+1)+20*INT (I/2)
760 LET B(I+J)=(INT (RND*20)+1)+20*INT (I/2)
770 LET P(I+J)=(INT (RND*20)+1)+20*INT (I/2)
780 NEXT J
790 NEXT I
800 FOR I=0 TO 9
810 FOR J=1 TO 3
820 LET T(I*3+J)=R(J,S(I+1))
830 LET C(I*3+J)=R(J,B(I+1))
840 LET Q(I*3+J)=R(J,P(I+1))
850 NEXT J
860 NEXT I
870 FOR I=0 TO 2
880 FOR J=1 TO 3
890 LET X(I*3+J)=R(J,W(I+1))
900 FOR L=1 TO 3
910 LET GG=((J-1)*3)+(I*9)+L+9
920 LET X(GG)=R(L,X(I*3+J))
930 NEXT L
950 NEXT J
960 NEXT I
\n1000 CLS
\n1005 SLOW
\n1010 LET YL=INT ((YR-1)/20)+1
\n1015 IF YL>5 THEN LET YL=1
\n1020 PRINT "YOU ARE ON LEVEL ";YL
\n1024 LET YR=YR-(YL-1)*20
\n1026 IF YR>99 THEN LET YR=INT (RND*100)-1
\n1030 PRINT "YOU ARE IN ROOM ";YR
\n1032 IF YR=SR THEN PRINT "THERE IS A SWORD IN THE ROOM"
\n1037 IF YR=SR THEN LET SW=1
\n1040 FOR I=1 TO 30
\n1050 IF YR=T(I) THEN GOTO 1080
\n1060 NEXT I
\n1070 GOTO 1090
\n1080 PRINT "I SEE COBWEBS"
\n1090 FOR I=1 TO 36
\n1100 IF YR=X(I) THEN GOTO 1130
\n1110 NEXT I
\n1120 GOTO 1140
\n1130 PRINT "I SMELL A MONZXER"
\n1140 FOR I=1 TO 30
\n1150 IF YR=Q(I) THEN GOTO 1180
\n1160 NEXT I
\n1170 GOTO 1190
\n1180 PRINT "I FEEL A DRAFT"
\n1190 FOR I=1 TO 30
\n1200 IF YR=C(I) THEN GOTO 1230
\n1210 NEXT I
\n1220 GOTO 1240
\n1230 PRINT "BATS NEARBY"
\n1240 FOR I=1 TO 3
\n1250 IF YR=W(I) THEN GOTO 1280
\n1260 NEXT I
\n1270 GOTO 1300
\n1280 PRINT "THERE IS A MONZXER IN YOUR ROOM"
\n1281 IF SW=1 THEN GOTO 1285
\n1282 PRINT "AND IT ATE YOU,DUMMY"
\n1284 GOTO 3000
\n1285 PRINT "BUT YOU KILLED IT WITH YOUR SWORD"
\n1290 PAUSE 300
\n1292 LET DM=DM+1
\n1294 IF DM=3 THEN GOTO 2990
\n1295 IF I>3 THEN LET I=1
\n1297 LET W(I)=101
\n1298 GOTO 870
\n1300 FOR I=1 TO 10
\n1310 IF YR=B(I) THEN GOTO 1340
\n1320 NEXT I
\n1330 GOTO 1380
\n1340 CLS
\n1350 LET YR=(INT (RND*20)+1)+(YL-1)*20
\n1360 PRINT "BATS TOOK YOU TO ROOM ";YR-(YL-1)*20
\n1370 GOTO 1010
\n1380 FOR I=1 TO 10
\n1390 IF YR=S(I) THEN GOTO 1420
\n1400 NEXT I
\n1410 GOTO 1430
\n1420 PRINT "THERE IS A SPIDER IN YOUR ROOM AND HE IS HUNGRY"
\n1423 PRINT AT 9,10;"/\..\!!\!!\!!\../ % % "
\n1424 PRINT AT 10,9;"% %Q\''\''\''%Q% % % % % % % "
\n1425 PRINT AT 11,9;"% % \:.\..\.:% % \@@% % % % % % % % /"
\n1427 PRINT AT 12,17;"IL IL IL"
\n1428 PRINT AT 14,7;"YUM YUM EATEM UP"
\n1429 PAUSE 100
\n1430 FOR I=1 TO 10
\n1440 IF YR=P(I) THEN GOTO 1470
\n1450 NEXT I
\n1460 GOTO 1540
\n1470 IF YL=5 THEN GOTO 1520
\n1480 CLS
\n1490 PRINT "TSK, TSK, YOU FELL IN A PIT"
\n1500 LET YR=YR+20
\n1505 IF YL>=2 THEN GOTO 1540
\n1510 GOTO 1010
\n1520 PRINT "YOU FELL INTO A BOTTOMLESS PIT YOU TURKEY"
\n1530 GOTO 3000
\n1540 PRINT "TUNNELS TO ROOMS ";
\n1550 FOR I=1 TO 3
\n1560 PRINT " ";ABS (R(I,YR)-(YL-1)*20);
\n1570 NEXT I
\n1580 PRINT
\n1590 PRINT "YOU MUST MOVE OR SHOOT"
\n1600 PAUSE 900
\n1610 LET K$=INKEY$
\n1620 IF K$="M" THEN GOTO 1650
\n1630 IF K$="S" THEN GOTO 2000
\n1640 GOTO 1600
\n1650 FOR I=1 TO 10
\n1652 IF YR=S(I) THEN GOTO 1657
\n1654 NEXT I
\n1656 GOTO 1659
\n1657 PRINT "THE SPIDER IS MUNCHING ON YOU"
\n1658 GOTO 3000
\n1659 PRINT "WHICH ROOM?"
\n1660 INPUT YR1
\n1670 FOR I=1 TO 3
\n1680 IF YR1=ABS (R(I,YR)-(YL-1)*20) THEN GOTO 1720
\n1690 NEXT I
\n1700 PRINT "NO TUNNEL TO THIS ROOM...SIGNED, MONZXER"
\n1710 GOTO 1650
\n1720 LET YR=YR1+(YL-1)*20
\n1730 GOTO 1000
\n2000 LET S1=S1-1
\n2005 FOR I=1 TO 10
\n2010 IF YR=S(I) THEN GOTO 2035
\n2011 IF K$="S" THEN PRINT "MONZXER=Z OR SPIDER=D"
\n2012 PAUSE 900
\n2014 LET S$=INKEY$
\n2015 IF S$="Z" THEN GOTO 2060
\n2016 IF S$="D" THEN GOTO 2060
\n2017 GOTO 2012
\n2020 NEXT I
\n2030 GOTO 2060
\n2035 CLS
\n2036 GOSUB 3500
\n2037 PRINT AT 18,5;"YOU KILLED THE SPIDER..."
\n2038 PRINT "%H%U%R%R%A%Y% %H%U%R%R%A%Y"
\n2040 PAUSE 300
\n2043 IF I>10 THEN LET I=1
\n2045 LET S(I)=101
\n2050 GOTO 800
\n2060 CLS
\n2070 PRINT "MAKE A LIST OF 5 ROOMS FOR THE ARROWS FLIGHT"
\n2080 FOR I=2 TO 6
\n2090 INPUT A(I)
\n2100 PRINT A(I)
\n2105 LET A(I)=A(I)+(YL-1)*20
\n2110 NEXT I
\n2120 LET A(1)=YR
\n2130 FOR I=2 TO 6
\n2140 FOR J=1 TO 3
\n2150 IF A(I)=R(J,A(I-1)) THEN GOTO 2180
\n2160 NEXT J
\n2165 LET J=INT (RND*3)+1
\n2170 LET A(I)=R(J,A(I-1))
\n2180 FOR J=1 TO 3
\n2190 IF A(I)=W(J) AND S$="Z" THEN GOTO 2220
\n2195 IF YR=S(I) AND S$="D" THEN GOTO 2215
\n2200 NEXT J
\n2210 GOTO 2230
\n2215 PRINT "YOU SLEW A SPIDER"
\n2217 GOSUB 3500
\n2218 GOTO 2040
\n2220 PRINT "YOU SLEW A MONZXER"
\n2221 IF J>3 THEN LET J=1
\n2222 LET W(J)=101
\n2223 PAUSE 300
\n2224 LET DM=DM+1
\n2225 IF DM=3 THEN GOTO 2990
\n2226 IF S1=0 THEN GOTO 2283
\n2228 GOTO 870
\n2230 IF NOT A(I)=YR THEN GOTO 2260
\n2240 PRINT "YOU SHOT YOURSELF"
\n2250 GOTO 3000
\n2260 NEXT I
\n2265 IF S$="D" THEN GOTO 2275
\n2270 PRINT "YOU MISSED THE MONZXER"
\n2273 GOTO 2280
\n2275 PRINT "YOU MISSED THE SPIDER"
\n2280 PAUSE 300
\n2283 IF S1=0 THEN PRINT "YOU ARE OUT OF ARROWS"
\n2285 IF S1=0 THEN GOTO 3000
\n2290 GOTO 1000
\n2990 PRINT "NO MORE MONZXERS YOU WIN ...SHUCKS"
\n3000 PAUSE 600
\n3005 CLS
\n3010 PRINT AT 10,10;"PLAY AGAIN?"
\n3030 LET K$=INKEY$
\n3040 IF K$="Y" THEN GOTO 3070
\n3050 IF K$="N" THEN GOTO 3130
\n3060 GOTO 3020
\n3070 PRINT AT 10,6;"SAME TUNNEL SET?"
\n3090 LET K$=INKEY$
\n3100 IF K$="Y" THEN GOTO 525
\n3110 IF K$="N" THEN GOTO 398
\n3112 GOTO 3090
\n3130 CLS
\n3135 FAST
\n3140 PRINT AT 10,20;"HAR HAR"
\n3150 PRINT AT 12,18;"YOU LOSE"
\n3160 LET END=1
\n3165 FAST
\n3170 GOTO 70
\n3500 PRINT AT 10,9;"TT TT TT"
\n3510 PRINT AT 11,8;"/% % % % % % % % \@@% % \:'\''\':% % "
\n3520 PRINT AT 12,5;">>===%=%=%>% % % % % %Q\..\..\..%Q% "
\n3530 PRINT AT 13,11;"% % % % % /\;;\;;\;;\''/"
\n3540 PRINT AT 14,12;"% % % "
\n3542 PRINT AT 9,20;"? ?"
\n3544 PRINT AT 7,24;"?"
\n3546 PRINT AT 5,27;"?"
\n3550 PRINT AT 16,22;"YA GOT ME"
\n3560 RETURN
\n3570 CLEAR
\n3580 SAVE "1026%4"
\n3590 RUN
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.
