Enhanced BASIC, amazing.bas by Lee Davison
[Back]
Introduction
This program generates random mazes from 2x2 to 26x14. The original version appeared in Creative Computing.amazing.bas
10 ? TAB(9);"Amazing program" 20 ? TAB(7);"Creative Computing" 30 ? TAB(6);"Morristown New Jersey" 40 ? 50 ? TAB(9);"EhBASIC version" 60 ? TAB(9);"by Lee Davison" 70 ? TAB(5);"leeedavison@lycos.co.uk" 80 ? 100 INPUT "Please enter width and length";H,V 110 IF ((H>1) AND (H<27)) AND ((V>1) AND (V<15)) THEN 140 130 ? "Too big or small, please try again" : GOTO 100 140 DIM W(H,V),V(H,V) 150 ? 160 Q=0:Z=0:X=INT(RND(0)*H+1) 165 FOR I=1 TO H 170 IF I=X THEN ? "+ "; : GOTO 180 175 ? "+--"; 180 NEXT I 190 ? "+" 195 C=1:W(X,1)=C:INC C 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:INC S:GOTO 250 240 INC R 250 IF W(R,S)=0 THEN 210 260 IF R=1 THEN 530 265 IF W(R-1,S) THEN 530 270 IF S=1 THEN 390 280 IF W(R,S-1) THEN 390 290 IF R=H THEN 330 300 IF W(R+1,S) THEN 330 310 X=INT(RND(0)*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) THEN 370 350 X=INT(RND(0)*3+1) 360 ON X GOTO 790,820,910 370 X=INT(RND(0)*2+1) 380 ON X GOTO 790,820 390 IF R=H THEN 470 400 IF W(R+1,S) 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) THEN 450 430 X=INT(RND(0)*3+1) 440 ON X GOTO 790,860,910 450 X=INT(RND(0)*2+1) 460 ON X GOTO 790,860 470 IF S<>V THEN 490 480 IF Z=1 THEN 790 485 Q=1:GOTO 500 490 IF W(R,S+1) THEN 790 500 X=INT(RND(0)*2+1) 510 ON X GOTO 790,910 530 IF S=1 THEN 670 540 IF W(R,S-1) THEN 670 545 IF R=H THEN 610 547 IF W(R+1,S) 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) THEN 590 570 X=INT(RND(0)*3+1) 580 ON X GOTO 820,860,910 590 X=INT(RND(0)*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) THEN 660 640 X=INT(RND(0)*2+1) 650 ON X GOTO 820,910 660 GOTO 820 670 IF R=H THEN 740 680 IF W(R+1,S) 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) THEN 730 710 X=INT(RND(0)*2+1) 720 ON X GOTO 860,910 730 GOTO 860 740 IF S<>V THEN 760 750 IF Z=1 THEN 210 755 Q=1:GOTO 910 760 IF W(R,S+1) THEN 210 770 GOTO 910 790 W(R-1,S)=C 800 INC C:V(R-1,S)=2:DEC R 810 IF C=H*V+1 THEN 1010 815 Q=0:GOTO 260 820 W(R,S-1)=C 830 INC C 840 V(R,S-1)=1:DEC S:IF C=H*V+1 THEN 1010 850 Q=0:GOTO 260 860 W(R+1,S)=C 870 INC C:IF V(R,S)=0 THEN 880 875 V(R,S)=3:GOTO 890 880 V(R,S)=2 890 INC R 900 IF C=H*V+1 THEN 1010 905 GOTO 530 910 IF Q=1 THEN 960 920 W(R,S+1)=C:INC C:IF V(R,S)=0 THEN 940 930 V(R,S)=3:GOTO 950 940 V(R,S)=1 950 INC S: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 210 980 V(R,S)=1:Q=0:R=1:S=1:GOTO 250 1010 FOR J=1 TO V 1020 ? "|"; 1025 FOR I=1 TO H 1030 IF V(I,J)AND-2 THEN ? " "; : GOTO 1040 1035 ? " |"; 1040 NEXT I 1045 ? 1050 FOR I=1 TO H 1055 IF V(I,J)AND-3 THEN ? "+ "; : GOTO 1070 1060 ? "+--"; 1070 NEXT I 1071 ? "+" 1072 NEXT J 1073 END