1
0
mirror of https://github.com/rfivet/BCG101.git synced 2024-12-23 10:37:15 -05:00
BCG101/factory/AMAZIN.BAS

86 lines
2.4 KiB
QBasic
Raw Normal View History

2024-04-23 03:54:06 -04:00
10 ' AMAZIN -- DRAW A MAZE UP TO 14 BY 21
20 ' EDUSYSTEM 50 REFACTORING BY RENAUD FIVET
90 DEF FNR(R)=INT(RND(1)*R+1)
100 RANDOMIZE
110 DIM V(13,20)
120 PRINT "WHAT ARE YOUR WIDTH AND LENGTH";\ INPUT H,V
122 PRINT
130 IF H<2 THEN 132\ IF H>14 THEN 132
131 IF V<2 THEN 132\ IF V<=21 THEN 150
132 PRINT "MEANINGLESS DIMENSIONS, TRY AGAIN"
140 PRINT
141 GOTO 120
150 PRINT
151 PRINT
160 ' PICK ENTRY CELL ON TOP ROW AND DRAW UPPER WALL
161 C=H*V ' COUNT OF CELLS LEFT TO FILL
162 R=FNR(H)-1 ' R,0 TOP ENTRY CELL COORD
163 H=H-1\ V=V-1 ' COORD IN 0..H,0..V
170 FOR I=0 TO H
171 IF I=R THEN 174
172 PRINT ":--";
173 GOTO 175
174 PRINT ": ";
175 NEXT I
185 PRINT ":"
187 ' PICK EXIT CELL ON BOTTOM ROW AS CURRENT
190 R=FNR(H+1)-1\ S=V ' R,S CURRENT CELL COORD
192 V(R,S)=2
193 GOTO 999
2024-04-23 03:54:06 -04:00
209 ' SCAN FOR NEXT POSITION TO CHECK
210 R=R+1
215 IF R<=H THEN 250
220 R=0\ S=S+1
225 IF S<=V THEN 250
230 S=0
250 IF V(R,S)=0 THEN 210
255 ' CHECK FOR ADJACENT UNMARKED CELLS AND PICK ONE AT RANDOM
260 T=1
261 IF R=0 THEN 262\ IF V(R-1,S)<>0 THEN 262\ T=T+1 ' L
262 IF S=0 THEN 263\ IF V(R,S-1)<>0 THEN 263\ T=T+2 ' U
263 IF R=H THEN 264\ IF V(R+1,S)<>0 THEN 264\ T=T+4 ' R
264 IF S=V THEN 265\ IF V(R,S+1)<>0 THEN 265\ T=T+8 ' D
265 ' 0, L, U, LU, R, LR, UR,LUR, D, LD, UD,LUD, RD,LRD,URD,LURD
300 ON T GOTO 210,790,820,370,860,450,590,310,910,500,640,350,710,430,570
310 ON FNR(3) GOTO 790,820,860 ' LUR
350 ON FNR(3) GOTO 790,820,910 ' LUD
370 ON FNR(2) GOTO 790,820 ' LU
430 ON FNR(3) GOTO 790,860,910 ' LRD
450 ON FNR(2) GOTO 790,860 ' LR
500 ON FNR(2) GOTO 790,910 ' LD
570 ON FNR(3) GOTO 820,860,910 ' URD
590 ON FNR(2) GOTO 820,860 ' UR
640 ON FNR(2) GOTO 820,910 ' UD
710 ON FNR(2) GOTO 860,910 ' RD
720 '
2024-04-23 03:54:06 -04:00
790 ' REMOVE LEFT WALL
800 R=R-1\ V(R,S)=3\ GOTO 999
2024-04-23 03:54:06 -04:00
820 ' REMOVE UP WALL
830 S=S-1\ V(R,S)=2\ GOTO 999
2024-04-23 03:54:06 -04:00
860 ' REMOVE RIGHT WALL
870 V(R,S)=V(R,S)+2\ R=R+1\ GOTO 998
2024-04-23 03:54:06 -04:00
910 ' REMOVE DOWN WALL
922 V(R,S)=V(R,S)+1\ S=S+1
998 V(R,S)=1
2024-04-23 03:54:06 -04:00
999 C=C-1\ IF C>0 THEN 260 ' LOOP WHILE C
1000 ' DRAW MAZE
1010 FOR J=0 TO V
1011 PRINT "I";
1012 FOR I=0 TO H
1013 IF V(I,J)<3 THEN 1030
1020 PRINT " ";
1021 GOTO 1040
1030 PRINT " I";
1040 NEXT I
1041 PRINT
1043 FOR I=0 TO H
1045 IF V(I,J)<=1 THEN 1060
1050 IF V(I,J)=3 THEN 1060
1051 PRINT ": ";
1052 GOTO 1070
1060 PRINT ":--";
1070 NEXT I
1071 PRINT ":"
1072 NEXT J
1073 END