This is an old revision of the document!
EXPLORING AMAZING.BAS
BASIC Computer Games: Microcomputer Edition 1978
I have been haunted for a long time by a program called AMAZING.BAS which I (and more than a million others) saw in BASIC Computer Games: Microcomputer Edition, edited by David H. Ahl back in 1978.
I still have a copy of this book, partly because I really like George Beker's robot illustrations.
That code is below, but without comments and loaded with GOTO pointing to GOTO … I've never really understood how it worked.
AMAZING.BAS
10 PRINT TAB(28);"AMAZING PROGRAM" 20 PRINT TAB(15);"CREATIVE COMPUTING MORRISTOWN, NEW JERSEY" 30 PRINT:PRINT:PRINT:PRINT 100 INPUT "WHAT ARE YOUR WIDTH AND LENGTH";H,V 102 IF H<>1 AND V<>1 THEN 110 104 PRINT "MEANINGLESS DIMENSIONS. TRY AGAIN.":GOTO 100 110 DIM W(H,V),V(H,V) 120 PRINT 130 PRINT 140 PRINT 150 PRINT 160 Q=0:Z=0:X=INT(RND(1)*H+1) 165 FOR I=1 TO H 170 IF I=X THEN 173 171 PRINT ".--";:GOTO 180 173 PRINT ". "; 180 NEXT I 190 PRINT "." 195 C=1:W(X,1)=C:C=C+1 200 R=X:S=1:GOTO 260 210 IF R<>H THEN 240 215 IF S<>V THEN 230 220 R=1:S=1:GOTO 250 230 R=1:S=S+1:GOTO 250 240 R=R+1 250 IF W(R,S)=0 THEN 210 260 IF R-1=0 THEN 530 265 IF W(R-1,S)<>0 THEN 530 270 IF S-1=0 THEN 390 280 IF W(R,S-1)<>0 THEN 390 290 IF R=H THEN 330 300 IF W(R+1,S)<>0 THEN 330 310 X=INT(RND(1)*3+1) 320 ON X GOTO 790,820,860 330 IF S<>V THEN 340 334 IF Z=1 THEN 370 338 Q=1:GOTO 350 340 IF W(R,S+1)<>0 THEN 370 350 X=INT(RND(1)*3+1) 360 ON X GOTO 790,820,910 370 X=INT(RND(1)*2+1) 380 ON X GOTO 790,820 390 IF R=H THEN 470 400 IF W(R+1,S)<>0 THEN 470 405 IF S<>V THEN 420 410 IF Z=1 THEN 450 415 Q=1:GOTO 430 420 IF W(R,S+1)<>0 THEN 450 430 X=INT(RND(1)*3+1) 440 ON X GOTO 790,860,910 450 X=INT(RND(1)*2+1) 460 ON X GOTO 790,860 470 IF S<>V THEN 490 480 IF Z=1 THEN 520 485 Q=1:GOTO 500 490 IF W(R,S+1)<>0 THEN 520 500 X=INT(RND(1)*2+1) 510 ON X GOTO 790,910 520 GOTO 790 530 IF S-1=0 THEN 670 540 IF W(R,S-1)<>0 THEN 670 545 IF R=H THEN 610 547 IF W(R+1,S)<>0 THEN 610 550 IF S<>V THEN 560 552 IF Z=1 THEN 590 554 Q=1:GOTO 570 560 IF W(R,S+1)<>0 THEN 590 570 X=INT(RND(1)*3+1) 580 ON X GOTO 820,860,910 590 X=INT(RND(1)*2+1) 600 ON X GOTO 820,860 610 IF S<>V THEN 630 620 IF Z=1 THEN 660 625 Q=1:GOTO 640 630 IF W(R,S+1)<>0 THEN 660 640 X=INT(RND(1)*2+1) 650 ON X GOTO 820,910 660 GOTO 820 670 IF R=H THEN 740 680 IF W(R+1,S)<>0 THEN 740 685 IF S<>V THEN 700 690 IF Z=1 THEN 730 695 Q=1:GOTO 830 700 IF W(R,S+1)<>0 THEN 730 710 X=INT(RND(1)*2+1) 720 ON X GOTO 860,910 730 GOTO 860 740 IF S<>V THEN 760 750 IF Z=1 THEN 780 755 Q=1:GOTO 770 760 IF W(R,S+1)<>0 THEN 780 770 GOTO 910 780 GOTO 1000 790 W(R-1,S)=C 800 C=C+1:V(R-1,S)=2:R=R-1 810 IF C=H*V+1 THEN 1010 815 Q=0:GOTO 260 820 W(R,S-1)=C 830 C=C+1 840 V(R,S-1)=1:S=S-1:IF C=H*V+1 THEN 1010 850 Q=0:GOTO 260 860 W(R+1,S)=C 870 C=C+1:IF V(R,S)=0 THEN 880 875 V(R,S)=3:GOTO 890 880 V(R,S)=2 890 R=R+1 900 IF C=H*V+1 THEN 1010 905 GOTO 530 910 IF Q=1 THEN 960 920 W(R,S+1)=C:C=C+1:IF V(R,S)=0 THEN 940 930 V(R,S)=3:GOTO 950 940 V(R,S)=1 950 S=S+1:IF C=H*V+1 THEN 1010 955 GOTO 260 960 Z=1 970 IF V(R,S)=0 THEN 980 975 V(R,S)=3:Q=0:GOTO 1000 980 V(R,S)=1:Q=0:R=1:S=1:GOTO 250 1000 GOTO 210 1010 FOR J=1 TO V 1011 PRINT "I"; 1012 FOR I=1 TO H 1013 IF V(I,J)<2 THEN 1030 1020 PRINT " "; 1021 GOTO 1040 1030 PRINT " I"; 1040 NEXT I 1041 PRINT 1043 FOR I=1 TO H 1045 IF V(I,J)=0 THEN 1060 1050 IF V(I,J)=2 THEN 1060 1051 PRINT ": "; 1052 GOTO 1070 1060 PRINT ":--"; 1070 NEXT I 1071 PRINT "." 1072 NEXT J 1073 END
BASIC Computer Games - Microcomputer Edition
I spent a long time tracing loops of spaghetti code and making guesses but never really got much farther than sorting out what was code doing something to the North, East, South, or West of a current point.
That still told me nothing of the real magic making mazes.
The Original
Recently, I ran across a Medium article by Jorge Castro lamenting how tough it was to understand the 1978 version of AMAZING.BAS.
The article included an archived copy of AMAZING described as the original code which had comments included.
It became immediately obvious this code underwent (suffered?) drastic changes before publication in 1973 Creative Computing or the 1978 BASIC Computer Games book.
Original comments were stripped, likely to save memory and make it simpler to type in, and the entire straightforward direction checking logic was replaced with crazy spaghetti.
The only reason I can imagine to do so was to fit the constraints of the DEC EduSystem 30 BASIC used for the 1973 Creative Computing sample runs.
The three versions (1972 vs. 1973 and 1978) are as different as night and day for understandability.
Compare this original code below to the spaghetti code version above.
100 ' NAME: AMAZING*** 105 ' 110 ' BY: Jack Hauber and S. J. Garland on 12/13/72 115 ' 120 ' DESCRIPTION: Constructs a maze of any size the user wishes (up 125 ' to 25 rows by 23 columns). Each maze is unique and guaranteed 130 ' to have only one solution. 135 ' 140 ' INSTRUCTIONS: Type "RUN" for complete instructions. 145 ' 150 ' CATEGORY: DEMONS*** 155 ' 160 ' LANGUAGE: BASIC 165 ' 170 ' INDEX LINE: 175 ' |Constructs unique, 1 solution |maze 180 ' 185 ' 220 RANDOMIZE 230 PRINT "THIS PROGRAM WILL PRINT A DIFFERENT MAZE EACH TIME IT IS" 240 PRINT "RUN. THERE WILL BE A UNIQUE PATH THROUGH THE MAZE. YOU" 250 PRINT "CAN CHOOSE ANY DIMENSIONS FOR THE MAZE UP TO 25 SQUARES" 260 PRINT "LONG AND 23 SQUARES WIDE." 270 PRINT 280 PRINT "WHAT ARE YOUR LENGTH AND WIDTH (E. G. 13,10)"; 290 INPUT R9, C9 300 DIM W(25,23), V(25,23) 310 LET N9 = R9*C9 320 MAT W = ZER(R9,C9) 'KEEPS TRACK OF SQUARES VISITED 330 MAT V = ZER(R9,C9) 'AND THEIR RIGHT, BOTTOM WALLS 340 LET B = 0 'FLAG NO EXIT TO BOTTOM YET 350 REM FIND SQUARE IN WHICH TO START 360 LET F = INT(RND*C9+1) 370 PRINT 'PRINT TOP BORDER 380 FOR C = 1 TO C9 390 IF C = F THEN 420 400 PRINT ":--"; 410 GOTO 430 420 PRINT ": "; 430 NEXT C 440 PRINT ":" 450 LET R = 1 'START IN FIRST ROW 460 LET C = F 'AND COLUMN UNDER HOLE IN BORDER 470 LET N = 1 'COUNT OF SQUARES VISITED 480 LET W(R,C) = N 490 ' 500 ' A CORRIDOR IS CONSTRUCTED BY MOVING IN A RANDOM DIRECTION FROM 510 ' THE CURRENT SQUARE TO SOME SQUARE THAT HAS NOT BEEN VISITED 520 ' YET AND ERASING THE WALL BETWEEN THE TWO SQUARES. IF NO SUCH 530 ' MOVE IS POSSIBLE, A SIDE CORRIDOR IS STARTED IN SOME SQUARE 540 ' ALREADY VISITED WHICH IS ADJACENT TO AN UNVISITED SQUARE. ONLY 550 ' ONE EXIT TO THE BOTTOM OF THE MAZE IS ALLOWED. 560 ' 570 REM MAKE LIST OF UNBLOCKED DIRECTIONS 580 LET D = 0 590 REM CAN WE GO LEFT 600 IF C = 1 THEN 640 'NO, ON BORDER 610 IF W(R,C-1) > 0 THEN 640 'NO, SQUARE USED ALREADY 620 LET D = D+1 'YES, ADD "LEFT" TO LIST 630 LET D(D) = 1 640 REM CAN WE GO RIGHT 650 IF C = C9 THEN 690 'NO, ON BORDER 660 IF W(R,C+1) > 0 THEN 690 'NO, SQUARE USED ALREADY 670 LET D = D+1 'YES, ADD "RIGHT" TO LIST 680 LET D(D) = 2 690 REM CAN WE GO UP 700 IF R = 1 THEN 740 'NO, ON BORDER 710 IF W(R-1,C) > 0 THEN 740 'NO, SQUARE USED ALREADY 720 LET D = D+1 'YES, ADD "UP" TO LIST 730 LET D(D) = 3 740 REM CAN WE GO DOWN 750 IF R < R9 THEN 780 'MAYBE, NOT ON BORDER 760 IF B = 1 THEN 810 'NO, ALREADY HAVE EXIT TO BOTTOM 770 GOTO 790 'YES, ALLOW EXIT TO BOTTOM 780 IF W(R+1,C) > 0 THEN 810 'NO, SQUARE USED ALREADY 790 LET D = D+1 'YES, ADD "DOWN" TO LIST 800 LET D(D) = 4 810 REM CHOOSE DIRECTION 820 IF D = 0 THEN 1090 'ALL DIRECTIONS BLOCKED 830 LET X = INT(D*RND+1) 'PICK RANDOM DIRECTION 840 ON D(X) GOTO 850,890,930,970 850 REM GO LEFT 860 LET C = C-1 870 LET V(R,C) = 2 'NEW SQUARE HAS ONLY BOTTOM WALL 880 GOTO 1030 890 REM GO RIGHT 900 LET V(R,C) = V(R,C) + 2 'ERASE RIGHT WALL OF THIS SQUARE 910 LET C = C+1 920 GOTO 1030 930 REM GO UP 940 LET R = R-1 950 LET V(R,C) = 1 'NEW SQUARE HAS ONLY RIGHT WALL 960 GOTO 1030 970 REM GO DOWN 980 LET V(R,C) = V(R,C) + 1 'ERASE BOTTOM WALL OF THIS SQUARE 990 LET R = R+1 1000 IF R <= R9 THEN 1030 'STILL IN MAZE 1010 LET B = 1 'FLAG EXIT TO BOTTOM 1020 GOTO 1140 'AND GO VISIT OTHER SQUARES 1030 REM MARK SQUARE AS USED 1040 LET N = N+1 1050 LET W(R,C) = N 1060 IF N < N9 THEN 570 1070 REM DONE 1080 GOTO 1180 1090 REM RESTART IN USED SQUARE ADJACENT TO UNUSED SQUARE 1100 LET C = C+1 1110 IF C <= C9 THEN 1160 1120 LET R = R+1 1130 IF R <= R9 THEN 1150 1140 LET R = 1 1150 LET C = 1 1160 IF W(R,C) > 0 THEN 570 1170 GOTO 1100 1180 REM PRINT OUT MAZE 1190 FOR R = 1 TO R9 1200 PRINT "I"; 1210 FOR C = 1 TO C9 1220 IF V(R,C) < 2 THEN 1250 1230 PRINT " "; 1240 GOTO 1260 1250 PRINT " I"; 1260 NEXT C 1270 PRINT 1280 FOR C = 1 TO C9 1290 IF MOD(V(R,C),2) = 0 THEN 1320 1300 PRINT ": "; 1310 GOTO 1330 1320 PRINT ":--"; 1330 NEXT C 1340 PRINT ":" 1350 NEXT R 1360 END
Source: Amazing Programming Code by Jorge Castro … with recent comments by S. J. Garland!
This version is spaghetti-free and made it possible to understand what is really going on.
Adapting The Original
I worked through the new-to-me original version, adapting it to the Color Computer family of computers, which was surprisingly easy.
Microsoft BASIC ruled the world in the late 1970s an early 1980s and there were no end of magazines and books at the time which included a program with blocks of how to customize it for other computers of the day.
I commented out a RANDOMIZE line (220), two MAT lines (320-330), and a MOD line (1290) with keywords not implemented in the Color Computer family of Microsoft BASICs.
I added a handful of lines (221-225) to replace the RANDOMIZE and demonstrate a way in BASIC to detect which of the different Color Computer family of machines a program is running on.
Next, I replaced RND calculation in two lines (360 and 830) to account for differences in how the various BASIC RND functions work.
Then I replaced the MOD function with a similar formula.
Finally, I made a few other cosmetic changes (compared to the original above) such as spacing for the Color Computer 32-character wide screen, add a “generating the maze” notice, and move drawing the first row of the maze down to start drawing after the maze generation.
The version below was tested running on the Micro Color Computer (MC-10), Alice, Color Computer 1, 2, and 3, the Dragon 32 and 64 multiple times in the XRoar emulator to verify each run created a new random-ish or different maze.
Have fun with it on your Color Computer family machine.
100 REM NAME: AMAZING*** 105 REM 110 REM BY: JACK HAUBER AND S. J. GARLAND ON 12/13/72 115 REM 120 REM DESCRIPTION: CONSTRUCTS A MAZE OF ANY SIZE THE USER WISHES (UP 125 REM TO 25 ROWS BY 23 COLUMNS). EACH MAZE IS UNIQUE AND GUARANTEED 130 REM TO HAVE ONLY ONE SOLUTION. 135 REM 140 REM INSTRUCTIONS: TYPE "RUN" FOR COMPLETE INSTRUCTIONS. 145 REM 150 REM CATEGORY: DEMONS*** 155 REM 160 REM LANGUAGE: BASIC 165 REM 170 REM INDEX LINE: 175 REM CONSTRUCTS UNIQUE, 1 SOLUTION MAZE 180 REM 185 REM 220 REM RANDOMIZE 221 A=PEEK(65534)*256+PEEK(65535) 222 IF A=63278 THEN T=PEEK(9)*256+PEEK(10):X=RND(-T):REM MC-10/ALICE 223 IF A=40999 THEN X=RND(-TIMER):REM COCO1/2 224 IF A=46004 THEN X=RND(-TIMER):REM DRAGON 225 IF A=35867 THEN X=RND(-TIMER):REM COCO3 230 PRINT "THIS PROGRAM WILL PRINT A" 231 PRINT "DIFFERENT MAZE EACH TIME IT IS" 240 PRINT "RUN. THERE WILL BE A UNIQUE" 241 PRINT "PATH THROUGH THE MAZE. YOU CAN" 250 PRINT "CHOOSE ANY DIMENSIONS FOR THE" 251 PRINT "MAZE UP TO THE LIMIT OF RAM." 260 REM PRINT "LONG AND 23 SQUARES WIDE." 270 PRINT 280 PRINT "WHAT ARE YOUR LENGTH AND WIDTH" 281 PRINT "(E. G. 6,10)"; 290 INPUT R9, C9 300 DIM W(R9,C9), V(R9,C9) 310 N9 = R9*C9 320 REM MAT W = ZER(R9,C9) REM KEEPS TRACK OF SQUARES VISITED 330 REM MAT V = ZER(R9,C9) REM AND THEIR RIGHT, BOTTOM WALLS 340 B = 0 :REM FLAG NO EXIT TO BOTTOM YET 350 REM FIND SQUARE IN WHICH TO START 360 REM F = INT(RND*C9+1) 361 F = RND(C9) 370 PRINT "GENERATING MAZE. PLEASE WAIT..." 450 R = 1 :REM START IN FIRST ROW 460 C = F :REM AND COLUMN UNDER HOLE IN BORDER 470 N = 1 :REM COUNT OF SQUARES VISITED 480 W(R,C) = N 490 REM 500 REM A CORRIDOR IS CONSTRUCTED BY MOVING IN A RANDOM DIRECTION FROM 510 REM THE CURRENT SQUARE TO SOME SQUARE THAT HAS NOT BEEN VISITED 520 REM YET AND ERASING THE WALL BETWEEN THE TWO SQUARES. IF NO SUCH 530 REM MOVE IS POSSIBLE, A SIDE CORRIDOR IS STARTED IN SOME SQUARE 540 REM ALREADY VISITED WHICH IS ADJACENT TO AN UNVISITED SQUARE. ONLY 550 REM ONE EXIT TO THE BOTTOM OF THE MAZE IS ALLOWED. 560 REM 570 REM MAKE LIST OF UNBLOCKED DIRECTIONS 580 D = 0 590 REM CAN WE GO LEFT 600 IF C = 1 THEN 640 :REM NO, ON BORDER 610 IF W(R,C-1) > 0 THEN 640 :REM NO, SQUARE USED ALREADY 620 D = D+1 :REM YES, ADD "LEFT" TO LIST 630 D(D) = 1 640 REM CAN WE GO RIGHT 650 IF C = C9 THEN 690 :REM NO, ON BORDER 660 IF W(R,C+1) > 0 THEN 690 :REM NO, SQUARE USED ALREADY 670 D = D+1 :REM YES, ADD "RIGHT" TO LIST 680 D(D) = 2 690 REM CAN WE GO UP 700 IF R = 1 THEN 740 :REM NO, ON BORDER 710 IF W(R-1,C) > 0 THEN 740 :REM NO, SQUARE USED ALREADY 720 D = D+1 :REM YES, ADD "UP" TO LIST 730 D(D) = 3 740 REM CAN WE GO DOWN 750 IF R < R9 THEN 780 :REM MAYBE, NOT ON BORDER 760 IF B = 1 THEN 810 :REM NO, ALREADY HAVE EXIT TO BOTTOM 770 GOTO 790 :REM YES, ALLOW EXIT TO BOTTOM 780 IF W(R+1,C) > 0 THEN 810 :REM NO, SQUARE USED ALREADY 790 D = D+1 :REM YES, ADD "DOWN" TO LIST 800 D(D) = 4 810 REM CHOOSE DIRECTION 820 IF D = 0 THEN 1090 :REM ALL DIRECTIONS BLOCKED 830 REM X = INT(D*RND+1) REM PICK RANDOM DIRECTION 831 X = RND(D) 840 ON D(X) GOTO 850,890,930,970 850 REM GO LEFT 860 C = C-1 870 V(R,C) = 2 :REM NEW SQUARE HAS ONLY BOTTOM WALL 880 GOTO 1030 890 REM GO RIGHT 900 V(R,C) = V(R,C) + 2 :REM ERASE RIGHT WALL OF THIS SQUARE 910 C = C+1 920 GOTO 1030 930 REM GO UP 940 R = R-1 950 V(R,C) = 1 :REM NEW SQUARE HAS ONLY RIGHT WALL 960 GOTO 1030 970 REM GO DOWN 980 V(R,C) = V(R,C) + 1 :REM ERASE BOTTOM WALL OF THIS SQUARE 990 R = R+1 1000 IF R <= R9 THEN 1030 :REM STILL IN MAZE 1010 B = 1 :REM FLAG EXIT TO BOTTOM 1020 GOTO 1140 :REM AND GO VISIT OTHER SQUARES 1030 REM MARK SQUARE AS USED 1040 N = N+1 1050 W(R,C) = N 1060 IF N < N9 THEN 570 1070 REM DONE 1080 GOTO 1180 1090 REM RESTART IN USED SQUARE ADJACENT TO UNUSED SQUARE 1100 C = C+1 1110 IF C <= C9 THEN 1160 1120 R = R+1 1130 IF R <= R9 THEN 1150 1140 R = 1 1150 C = 1 1160 IF W(R,C) > 0 THEN 570 1170 GOTO 1100 1180 REM PRINT OUT MAZE 1181 CLS: PRINT :REM PRINT TOP BORDER 1182 FOR C = 1 TO C9 1183 IF C = F THEN 1186 1184 PRINT ":--"; 1185 GOTO 1187 1186 PRINT ": "; 1187 NEXT C 1188 PRINT ":" 1190 FOR R = 1 TO R9 1200 PRINT "I"; 1210 FOR C = 1 TO C9 1220 IF V(R,C) < 2 THEN 1250 1230 PRINT " "; 1240 GOTO 1260 1250 PRINT " I"; 1260 NEXT C 1270 PRINT 1280 FOR C = 1 TO C9 1290 REM IF MOD(V(R,C),2) = 0 THEN 1320 1292 IF V(R,C) - (INT(V(R,C)/2) * 2) = 0 THEN 1320 1300 PRINT ": "; 1310 GOTO 1330 1320 PRINT ":--"; 1330 NEXT C 1340 PRINT ":" 1350 NEXT R 1360 END
With thanks to PenguinOfEvil and George Phillips on the CoCo Discord for MC-10 timer information.
How It Works
Two arrays are used to track the maze building.
Both arrays are initialized to zeroes.
One array tracks the walls of a square in the maze which will be “visible” when the final maze is drawn.
As the maze is explored in the maze generation step, square by square, the status of which walls exist for each square is updated.
The left hand annotated maze below shows the status of the walls.
By default, a square has a wall to the right, and a wall on the bottom and the maze generator may knock down one or both as it moves from square to square visiting all of the squares.
To knock down the wall to the left of a square, the generator moves its current column position 1 to the left, updates that square with the next count of visited squares then knocks down the right-hand wall.
To down down the wall in the up (or north) direction, the generator moves its current row position 1 row up, then knocks down the “bottom” wall of that square.
- 0 this square has right AND bottom walls
- 1 this square has right wall, erase bottom
- 2 this square has bottom wall, erase right
- 3 this square has no bottom or right wall
The other array tracks whether a room has been ““walked” or “explored” - each time a maze room is explored, it is given a unique integer number from an increating counter.
The right hand annotated example maze below shows the increating count for each square.
If the current row and column of the generator each a dead end or the exit and have no more directions to “dig”, then it will stop, rescan the array looking for any unused room next to an already dug room and start digging again from there.
You can see that in the order of the numbers in the right-hand annotated example maze.
It starts with square 1 below the randomly chosen entrance, builds a list of possible directions to dig out a new square, then does so, “knocking down” any right-hand or bottom walls it needs to as it goes.
|--| |--|--|--|--| |--| |--|--|--|--| | 3 2 1| 3 2 1| | 2 1 16|19 20 21| | |--| | |--| | | |--| | |--| | | 3 1| 2 0| 3 0| | 3 4|17 18|23 22| | | |--|--| |--| | | |--|--| |--| | 0| 2 2 1| 2 0| |36| 5 6 7|24 25| |--|--|--| |--|--| |--|--|--| |--|--| | 3 2 2 2 2 1| |28 27 26 8 9 10| | |--|--|--|--| | | |--|--|--|--| | | 1| 1| 3 3 2 0| |29|32|14 13 12 11| | | | | |--|--| | | | | |--|--| | 2 0| 1| 2 2 0| |30 31|15|33 34 35| |--|--| |--|--|--| |--|--| |--|--|--| V(R,C) array W(R,C) array 0 0 0 0 0 0 0 0 00 00 00 00 00 00 00 00 0 3 2 1 3 2 1 0 00 02 01 16 19 20 21 00 0 3 1 2 0 3 0 0 00 03 04 17 18 23 22 00 0 0 2 2 1 2 0 0 00 36 05 06 07 24 25 00 0 3 2 2 2 2 1 0 00 28 27 26 08 09 10 00 0 1 1 3 3 2 0 0 00 29 32 14 13 12 11 00 0 2 0 1 2 2 0 0 00 30 31 15 33 34 35 00 0 0 0 0 0 0 0 0 00 00 00 00 00 00 00 00
Without the spaghetti code, and with comments to help code the logic of the V(R,C) array controlling the “walls” it makes sense and you can see how the later more confusing versions still do the same thing, just in a different set of GOTO to GOTO steps.
Possible Adaptations
- Direct to PRINT#-2 or LPRINT to make maze printouts
- Set in a loop to redraw mazes of the same size as an easy screen saver
- Show or prompt for seeds to allow recreating mazes
Other Versions
The Amazing program has been adapted and changed for decades, with many versions appearing across github and gitlab these days.
MECC 1981
An early adaptation to the Apple computers from 1981, most notably to add lots of Apple II specific printer driver logic to print out the mazes.
Microsoft Small BASIC 2011
In 2010 and 2011, Microsoft built Small BASIC and to help a new generation of kids get into BASIC programming, worked with David Ahl and George Beker to port the 1978 book's Microsoft BASIC 3.0 code to the 2010 Small BASIC syntax.
BASIC Computer Games: Small BASIC Edition amazing.sb
It was great to see George Beker return to the robots of BASIC Computer Games, provide some background for the original robots that made the 1978 book so much more fun and bring some new robots as well!
Enjoy
Personally I am happy to finally understand that magical maze program after all this time.
▲ Return to Top