Trailing-Edge
-
PDP-10 Archives
-
decuslib20-01
-
decus/20-0020/amazin.dem
There are 2 other files named amazin.dem in the archive. Click here to see a list.
100' NAME--AMAZING
110'
120' DESCRIPTION--CONSTRUCTS A DIFFERENT MAZE EVERY TIME IT IS
130' RUN WITH ONLY ONE SOLUTION. THE USER CHOOSES THE DIMENSIONS
140' OF THE MAZE.
150'
160' SOURCE--JACK HAUBER, LOOMIS SCHOOL, WINDSOR CONNECTICUT.
170'
180' INSTRUCTIONS--TYPE "RUN" AND FOLLOW INSTRUCTIONS.
190'
200'
210' * * * * * * MAIN PROGRAM * * * * * * * * * * *
220'
230 RANDOMIZE
240 DIM W(25,103), V(25,103)
250 PRINT "THIS PROGRAM WILL PRINT OUT A DIFFERENT MAZE EVERY TIME IT"
260 PRINT "IS RUN AND GUARANTEES ONLY ONE PATH THROUGH. YOU CAN CHOOSE"
270 PRINT "THE DIMENSIONS OF THE MAZE. I.E. THE NUMBER OF SQUARES WIDE"
280 PRINT "AND THE NUMBER OF SQUARES LONG. A 23 BY 25 MAZE IS THE "
290 PRINT "MAXIMUM, BUT ANY DIMENSIONS UP TO THESE LIMITS ARE OK."
300 PRINT
310 PRINT "WHAT ARE YOUR WIDTH AND LENGTH";
320 INPUT H,V
330 PRINT
340 IF H<>1 THEN 390
350 IF V<>1 THEN 390
360 PRINT "MEANINGLESS DIMENSIONS, TRY AGAIN."
370 PRINT
380 GO TO 310
390 PRINT
400 PRINT
410 LET Q = 0
420 LET Z = 0
430
440
450 REM STEPS 1900 THRU 3200 PICK THE
460 REM SQUARE IN WHICH TO START.
470
480
490 LET X = INT(RND*H+1)
500 FOR I = 1 TO H
510 IF I = X THEN 540
520 PRINT ":--";
530 GOTO 550
540 PRINT ": ";
550 NEXT I
560 PRINT ":"
570 LET C = 1
580 LET W(X,1) = C
590 LET C = C+1
600 LET R = X
610 LET S = 1
620 GOTO 900
630
640
650 REM STEPS 4900 THRU 5700 LOOK FOR THE
660 REM SQUARE IN WHICH TO START A NEW
670 REM PATH WHEN THE OLD ONE GETS BLOCKED.
680 REM THE LINES ARE SCANNED FOR A SQUARE
690 REM WHICH HAS ALREADY BEEN USED BUT IS
700 REM ADJACENT TO AN OPEN SQUARE.
710
720
730 IF R <> H THEN 810
740 IF S <> V THEN 780
750 LET R = 1
760 LET S = 1
770 GOTO 890
780 LET R = 1
790 LET S = S+1
800 GOTO 890
810 LET R = R+1
820
830
840 REM STEPS 6500 THRU 13800 CHECK TO SEE
850 REM WHICH ADJACENT SQUARES ARE OPEN FOR
860 REM THE PATH TO FOLLOW.
870
880
890 IF W(R,S) = 0 THEN 730
900 IF R-1 = 0 THEN 1330
910 IF W(R-1,S) <> 0 THEN 1330
920 IF S-1 = 0 THEN 1100
930 IF W(R,S-1) <> 0 THEN 1100
940 IF R = H THEN 990
950 IF W(R+1,S) <> 0 THEN 990
960 LET X = INT(RND*3+1)
970 REM LEFT,UP,RIGHT
980 ON X GOTO 1850,1920,1990
990 IF S <> V THEN 1030
1000 IF Z = 1 THEN 1070
1010 LET Q = 1
1020 GOTO 1040
1030 IF W(R,S+1) <> 0 THEN 1070
1040 LET X = INT(RND*3+1)
1050 REM LEFT,UP,DOWN
1060 ON X GOTO 1850,1920,2090
1070 LET X = INT(RND*2+1)
1080 REM LEFT,UP
1090 ON X GOTO 1850,1920
1100 IF R = H THEN 1230
1110 IF W(R+1,S) <> 0 THEN 1230
1120 IF S<> V THEN 1160
1130 IF Z = 1 THEN 1200
1140 LET Q = 1
1150 GOTO 1170
1160 IF W(R,S+1) <> 0 THEN 1200
1170 LET X = INT(RND*3+1)
1180REM LEFT,RIGHT,DOWN
1190 ON X GOTO 1850,1990,2090
1200 LET X = INT(RND*2+1)
1210 REM LEFT,RIGHT
1220 ON X GOTO 1850,1990
1230 IF S <> V THEN 1270
1240 IF Z = 1 THEN 1320
1250 LET Q = 1
1260 GOTO 1280
1270 IF W(R,S+1) <> 0 THEN 1320
1280 LET X = INT(RND*2+1)
1290 REM LEFT,DOWN
1300 ON X GOTO 1850,2090
1310 REM LEFT
1320 GOTO 1850
1330 IF S-1 = 0 THEN 1580
1340 IF W(R,S-1) <> 0 THEN 1580
1350 IF R=H THEN 1480
1360 IF W(R+1,S) <> 0 THEN 1480
1370 IF S<> V THEN 1410
1380 IF Z = 1 THEN 1450
1390 LET Q = 1
1400 GOTO 1420
1410 IF W(R,S+1) <> 0 THEN 1450
1420 LET X = INT(RND*3+1)
1430 REM UP,RIGHT,DOWN
1440 ON X GOTO 1920,1990,2090
1450 LET X = INT(RND*2+1)
1460 REM UP,RIGHT
1470 ON X GOTO 1920,1990
1480 IF S <> V THEN 1520
1490 IF Z = 1 THEN 1570
1500 LET Q = 1
1510 GOTO 1530
1520 IF W(R,S+1) <> 0 THEN 1570
1530 LET X = INT(RND*2+1)
1540 REM UP,DOWN
1550 ON X GOTO 1920,2090
1560 REM UP
1570 GOTO 1920
1580 IF R = H THEN 1700
1590 IF W(R+1,S) <> 0 THEN 1700
1600 IF S <> V THEN 1640
1610 IF Z = 1 THEN 1690
1620 LET Q = 1
1630 GOTO 1650
1640 IF W(R,S+1) <> 0 THEN 1690
1650 LET X = INT(RND*2+1)
1660 REM RIGHT,DOWN
1670 ON X GOTO 1990,2090
1680 REM RIGHT
1690 GOTO 1990
1700 IF S <> V THEN 1740
1710 IF Z = 1 THEN 1780
1720 LET Q = 1
1730 GOTO 1760
1740 IF W(R,S+1) <> 0 THEN 1780
1750 REM DOWN
1760 GOTO 2090
1770 REM BLOCKED
1780 GOTO 2290
1790
1800
1810 REM STEPS 13900 THRU 18100 MAKE A RANDOM
1820 REM CHOICE OF AVAILABLE PATHS.
1830
1840
1850 LET W(R-1,S) = C
1860 LET C = C+1
1870 LET V(R-1,S) = 2
1880 LET R = R-1
1890 IF C = H*V+1 THEN 2310
1900 LET Q = 0
1910 GOTO 900
1920 LET W(R,S-1) = C
1930 LET C = C+1
1940 LET V(R,S-1) = 1
1950 LET S = S-1
1960 IF C = H*V+1 THEN 2310
1970 LET Q = 0
1980 GOTO 900
1990 LET W(R+1,S) = C
2000 LET C = C+1
2010 IF V(R,S) = 0 THEN 2040
2020 LET V(R,S) = 3
2030 GOTO 2050
2040 LET V(R,S) = 2
2050 LET R = R+1
2060 IF C = H*V+1 THEN 2310
2070 LET Q = 0
2080 GOTO 1330
2090 IF Q = 1 THEN 2190
2100 LET W (R,S+1) = C
2110 LET C = C+1
2120 IF V(R,S) = 0 THEN 2150
2130 LET V(R,S) = 3
2140 GOTO 2160
2150 LET V(R,S) = 1
2160 LET S = S+1
2170 IF C = H*V+1 THEN 2310
2180 GOTO 900
2190 LET Z = 1
2200 IF V(R,S) = 0 THEN 2240
2210 LET V(R,S) = 3
2220 LET Q = 0
2230 GOTO 2290
2240 LET V(R,S) = 1
2250 LET Q = 0
2260 LET R = 1
2270 LET S = 1
2280 GOTO 890
2290 GOTO 730
2300 REM PRINTS OUT THE MAZE FROM HERE ON.
2310 FOR J = 1 TO V
2320 PRINT "I";
2330 FOR I = 1 TO H
2340 IF V(I,J) < 2 THEN 2370
2350 PRINT " ";
2360 GOTO 2380
2370 PRINT " I";
2380 NEXT I
2390 PRINT
2400 FOR I = 1 TO H
2410 IF V(I,J) = 0 THEN 2450
2420 IF V(I,J) = 2 THEN 2450
2430 PRINT ": ";
2440 GOTO 2460
2450 PRINT ":--";
2460 NEXT I
2470 PRINT ":"
2480 NEXT J
2490 END