10 C0=0:C1=1:C2=2:C3=3:C4=4:C5=5:C6=6:C7=7:C8=8:C9=9
20 SC=1024:LL=40
30 DIMA(19,11),B(19,11)
40 A$(1)="":A$(2)="":A$(3)="":A$(4)=""
50 W$=""
60 SP$=""
70 M1=C0:PRINT""
80 INPUT"";H
90 IFH=C0ORH>19THENPRINT"";:GOTO80
100 INPUT"";V
110 IFV=C0ORV>10THENPRINT"";:GOTO100
120 PRINT""H""V"
130 A=H*V+C1
140 Q=C0:Z=C0:X=INT(H*RND(H))+C1
150 AA=X
160 A(X,0)=C1:C=C2
170 R=X:S=C1:GOTO240
180 IFR<>HGOTO220
190 IFS<>VGOTO210
200 R=C1:S=C1:GOTO230
210 R=C1:S=S+C1:GOTO230
220 R=R+C1
230 IFA(R,S−C1)=C0GOTO180
240 IFR−C1=C0GOTO560
250 IFA(R−C1,S−C1)GOTO560
260 IFS−C1=C0GOTO400
270 IFA(R,S−C2)GOTO400
280 IFR=HGOTO320
290 IFA(R+C1,S−C1)GOTO320
300 X=INT(C3*RND(C1))+C1
310 ONXGOTO870,910,950
320 IFS<>VGOTO350
330 IFZ=C1GOTO380
340 Q=C1:GOTO360
350 IFA(R,S)GOTO380
360 X=INT(C3*RND(C1))+C1
370 ONXGOTO870,910,1020
380 X=INT(C2*RND(C1))+C1
390 GOTO370
400 IFR=HGOTO500
410 IFA(R+C1,S−C1)GOTO500
420 IFS<>VGOTO450
430 IFZ=C1GOTO480
440 Q=C1:GOTO460
450 IFA(R,S)GOTO480
460 X=INT(C3*RND(C1))+C1
470 ONXGOTO870,950,1020
480 X=INT(C2*RND(C1))+C1
490 GOTO470
500 IFS<>VGOTO530
510 IFZ=C1GOTO870
520 Q=C1:GOTO540
530 IFA(R,S)GOTO870
540 X=INT(C2*RND(C1))+C1
550 ONXGOTO870,1020
560 IFS−C1=C0GOTO740
570 IFA(R,S−C2)GOTO740
580 IFR=HGOTO680
590 IFA(R+C1,S−C1)GOTO680
600 IFS<>VGOTO630
610 IFZ=C1GOTO660
620 Q=C1:GOTO640
630 IFA(R,S)GOTO660
640 X=INT(C3*RND(C1))+C1
650 ONXGOTO910,950,1020
660 X=INT(C2*RND(C1))+C1
670 GOTO650
680 IFS<>VGOTO710
690 IFZ=C1GOTO910
700 Q=C1:GOTO720
710 IFA(R,S)GOTO910
720 X=INT(C2*RND(C1))+C1
730 ONXGOTO910,1020
740 IFR=HGOTO820
750 IFA(R+C1,S−C1)GOTO820
760 IFS<>VGOTO790
770 IFZ=C1GOTO950
780 Q=C1:GOTO800
790 IFA(R,S)GOTO950
800 X=INT(C2*RND(C1))+C1
810 ONXGOTO950,1020
820 IFS<>VGOTO850
830 IFZ=C1GOTO180
840 Q=C1:GOTO860
850 IFA(R,S)GOTO180
860 GOTO1020
870 A(R−C1,S−C1)=C
880 C=C+C1:B(R−C1,S−C1)=C2:R=R−C1
890 IFC=AGOTO1120
900 Q=C0:GOTO240
910 A(R,S−C2)=C
920 C=C+C1
930 B(R,S−C2)=C1:S=S−C1:IFC=AGOTO1120
940 Q=C0:GOTO240
950 A(R+C1,S−C1)=C
960 C=C+C1:IFB(R,S−C1)=C0GOTO980
970 B(R,S−C1)=C3:GOTO990
980 B(R,S−C1)=C2
990 R=R+C1
1000 IFC=AGOTO1120
1010 GOTO560
1020 IFQ=C1GOTO1080
1030 A(R,S)=C:C=C+C1:IFB(R,S−C1)=C0GOTO1050
1040 B(R,S−C1)=C3:GOTO1060
1050 B(R,S−C1)=C1
1060 S=S+C1:IFC=AGOTO1120
1070 GOTO240
1080 Z=C1
1090 IFB(R,S−C1)=C0GOTO1110
1100 B(R,S−C1)=C3:Q=C0:GOTO180
1110 B(R,S−C1)=C1:Q=C0:R=C1:S=C1:GOTO230
1120 IFZ<>C1THENX=INT(H*RND(C1))+C1:B(X,V−C1)=B(X,V−C1)+C1
1130 GOSUB1140:POKESC+12*LL+18−H+LL*V+2*AA,30:GOTO1410
1140 REM PRINT MAZE ***
1150 M1=C1:PRINT"";:IFV=11THEN1170
1160 FORI=C1TO11−V:PRINT:NEXT
1170 FORJ=VTOC1STEP−C1:PRINTSPC(19−H)
1180 FORI=C1TOH:PRINT"";
1190 IFB(I,J−C1)=C0GOTO1230
1200 IFB(I,J−C1)=C2GOTO1230
1210 PRINT"";
1220 GOTO1240
1230 PRINT"";
1240 NEXTI
1250 PRINT"":REM FINISH LINE
1260 PRINTSPC(19−H)"";
1270 FORI=C1TOH:PRINT"";
1280 IFB(I,J−C1)VGOTO4520
1660 PRINT"";
1670 GETZ$:IFZ$=""GOTO1670
1680 IFZ$=""GOTO1730
1690 IFZ$=""GOTO1750
1700 IFZ$=""GOTO2210
1710 IFZ$=""GOTO1630
1720 GOTO1670
1730 Z=Z−C1:IFZC4THENZ=Z−C4
1760 GOTO2260
1770 RETURN
1780 IFZ=C1THENA1=A−C1:B1=B−C1:GOTO1830
1790 IFZ=C2ANDBC1THENA1=A:B1=B−C2:GOTO1830
1820 EL=C1:RETURN
1830 F=A(A1,B1):IFZ=C1GOTO1850
1840 FORI=C2TOZ:F=(FAND14)/C2+(FANDC1)*C8:NEXT
1850 EL=(FANDC2)/C2:RETURN
1860 IFZ=C1THENA1=A+C1:B1=B−C1:GOTO1910
1870 IFZ=C2ANDB>C1THENA1=A:B1=B−C2:GOTO1910
1880 IFZ=C3THENA1=A−C1:B1=B−C1:GOTO1910
1890 IFZ=C4ANDBVTHENE=C3:RETURN
1960 F=A(A,B−C1):IFZ=C1GOTO1980
1970 FORI=C2TOZ:F=(FAND14)/C2+(FANDC1)*C8:NEXT
1980 C=FANDC1:D=(FAND4)/C4:E=(FAND2)/C2
1990 IFC=C0THENGOSUB1780
2000 IFD=C0THENGOSUB1860
2010 RETURN
2020 C=C0:D=C0:E=−C1
2030 IFZ<>1GOTO2070
2040 E=C1
2050 IFA=WTHENE=C0
2060 RETURN
2070 IFZ=C3THENE=C2:RETURN
2080 IFZ=C2ANDA=HTHENE=C2:RETURN
2090 IFZ=C4ANDA=C1THENE=C2:RETURN
2100 RETURN
2110 IFE>C0GOTO2170
2120 IFZ=C1THENB=B+C1:RETURN
2130 IFZ=C2THENA=A+C1:RETURN
2140 IFZ=C3THENB=B−C1:RETURN
2150 IFZ=C4THENA=A−C1:RETURN
2160 PRINT"";:RETURN
2170 IFE=C0GOTO2190
2180 PRINT"";
2190 S=C1
2200 RETURN
2210 A=X:B=Y
2220 GOSUB1940
2230 GOSUB2110
2240 X=A:Y=B
2250 IFE>C0GOTO1650
2260 A=X:B=Y
2270 GOSUB1940
2280 REM DISPLAY 5 DEPTHS
2290 FORT=C1TO5
2300 GOSUB2410
2310 IFETHENT=C5:GOTO2350
2320 GOSUB2110
2330 GOSUB1940
2340 IFE>C1THENT=C5:GOTO2350
2350 NEXTT
2360 IFX=WANDY=C0ANDZ=C1GOTO2400
2370 IFX<>WANDY=C0ANDZ=C1THENGOSUB2160:PRINT"":GOTO2390
2380 GOTO2400
2390 GOSUB2160:PRINT"
2400 GOTO1650
2410 ONTGOTO2420,2780,3220,3710,4250
2420 REM DISPLAY DEPTH 1
2430 PRINT"";
2440 IFE>C2THENRETURN
2450 IFEC1THENGOSUB2180:RETURN
2460 FORI=C1TO21:IFC=C1THENPRINT"";:GOTO2520
2470 IFY=C0THENPRINT""MID$(W$,(IANDC1)+C1,C8);:GOTO2520
2480 IFEL=C1THENPRINT"";:GOTO2520
2490 IFI=C2THENPRINT"";:GOTO2520
2500 IFI<18THENPRINT"";:GOTO2520
2510 PRINT"";
2520 IFE=C0THENPRINTSPC(22);:GOTO2550
2530 IFY=C0THENPRINT""MID$(W$,(IANDC1)+C1,22);:GOTO2550
2540 PRINT"";
2550 IFD=C1THENPRINT"":GOTO2610
2560 IFY=C0THENPRINT""MID$(W$,(IANDC1)+C1,C8):GOTO2610
2570 IFER=C1THENPRINT"":GOTO2610
2580 IFI=C2THENPRINT"":GOTO2610
2590 IFI<18THENPRINT"":GOTO2610
2600 PRINT""
2610 NEXT
2620 FORI=C1TOC3:IFC=C1OR(X=WANDY=C0)GOTO2680
2630 IFI<>C1THEN2650
2640 IFEL=C0THENPRINT"";:GOTO2690
2650 PRINT""LEFT$(SP$,C8−I)""LEFT$(SP$,I−C1);
2660 IFI=C1GOTO2690
2670 GOTO2700
2680 PRINTSPC(C9−I)""LEFT$(SP$,I−C1);:IFI<>C1THEN2700
2690 IFE=C0THENPRINT"";:GOTO2710
2700 PRINT"";
2710 IFD=C1OR(X=WANDY=C0)GOTO2750
2720 IFI<>C1THEN2740
2730 IFER=C0THENPRINT"":GOTO2760
2740 PRINT""LEFT$(SP$,I−C1)""LEFT$(SP$,C8−I):GOTO2760
2750 PRINT""LEFT$(SP$,I−C1)""
2760 NEXTI
2770 RETURN
2780 REM DISPLAY DEPTH 2
2790 PRINT"";:Z$=""
2800 FORI=C1TOC2:PRINTZ$;:IFC=C0GOTO2830
2810 PRINTSPC(I+C1)"";SPC(C2−I);:GOTO2860
2820 PRINT"";:GOTO2860
2830 IFI=C1THENPRINTSPC(C4):GOTO2860
2840 IFEL=C1THENPRINT"";:GOTO2860
2850 PRINT"";
2860 IFE=C0ORI=C1THENPRINTSPC(14);:GOTO2880
2870 PRINT"";
2880 IFD=C0GOTO2900
2890 PRINTSPC(C2−I)"":GOTO2930
2900 IFI=C1THENPRINT:GOTO2930
2910 IFER=C1THENPRINT"":GOTO2930
2920 PRINT""
2930 NEXT
2940 FORI=C1TO15:PRINTZ$;:IFC=C1THENPRINT"";:GOTO2990
2950 IFEL=C1THENPRINT"";:GOTO2990
2960 IFI=C3THENPRINT"";:GOTO2990
2970 IFI>12THENPRINT"";:GOTO2990
2980 PRINT"";
2990 IFE=C0THENPRINT"";:GOTO3010
3000 PRINT"";
3010 IFD=C1THENPRINT"":GOTO3060
3020 IFER=C1THENPRINT"":GOTO3060
3030 IFI=C3THENPRINT"":GOTO3060
3040 IFI>12THENPRINT"":GOTO3060
3050 PRINT""
3060 NEXT
3070 FORI=C1TO4:PRINTZ$;:IFC=C1GOTO3120
3080 IFI<>C1GOTO3110
3090 IFEL=C0THENPRINT"";:GOTO3130
3100 PRINT"";:GOTO3130
3110 PRINT""LEFT$(SP$,C4−I)""LEFT$(SP$,I−C1);:GOTO3140
3120 PRINTSPC(C4−I)""LEFT$(SP$,I−C1);:IFI<>C1THEN3140
3130 IFE=C0THENPRINT"";:GOTO3150
3140 PRINT"";
3150 IFD=C1GOTO3190
3160 IFI<>C1THEN3180
3170 IFER=C0THENPRINT"":GOTO3200
3180 PRINT""LEFT$(SP$,I−C1)""LEFT$(SP$,C4−I):GOTO3200
3190 PRINT""LEFT$(SP$,I−C1)"":GOTO3200
3200 NEXTI
3210 RETURN
3220 REM DISPLAY DEPTH 3
3230 PRINT"";:Z$=Z$+""
3240 FORI=C1TO3:PRINTZ$;:IFC=C0GOTO3260
3250 PRINTSPC(I−C1)""SPC(C3−I);:GOTO3290
3260 IFIC7THENPRINT"";:GOTO3420
3410 PRINT"";
3420 IFE=C0THENPRINT"";:GOTO3440
3430 PRINT"";
3440 IFD=C1THENPRINT"":GOTO3490
3450 IFER=C1THENPRINT"":GOTO3490
3460 IFI=C2THENPRINT"":GOTO3490
3470 IFI>C7THENPRINT"":GOTO3490
3480 PRINT""
3490 NEXT
3500 FORI=C1TO3:PRINTZ$;:IFC=C1GOTO3560
3510 IFI<>C1THEN3530
3520 IFEL=C0THENPRINT"";:GOTO3570
3530 PRINT""LEFT$(SP$,C3−I)""LEFT$(SP$,I−C1);
3540 IFI=C1THEN3570
3550 GOTO3580
3560 PRINTSPC(C3−I)""LEFT$(SP$,I−C1);:GOTO3540
3570 IFE=C0THENPRINT"";:GOTO3590
3580 PRINT"";
3590 IFD=C1GOTO3650
3600 IFI<>C1THEN3620
3610 IFER=C0THENPRINT"":GOTO3690
3620 PRINT""LEFT$(SP$,I−C1)""LEFT$(SP$,C3−I):GOTO3690
3650 PRINT""LEFT$(SP$,I−C1)""
3690 NEXTI
3700 RETURN
3710 REM DISPLAY DEPTH 4
3720 PRINT"";:Z$=Z$+""
3730 FORI=C1TO2:PRINTZ$;:IFC=C0GOTO3770
3740 PRINTSPC(I−C1)""SPC(C2−I);:GOTO3810
3770 IFI=C1THENPRINT"";:GOTO3810
3790 IFEL=C1THENPRINT"";:GOTO3810
3800 PRINT"";
3810 IFE=C0ORI=C1THENPRINT"";:GOTO3830
3820 PRINT"";
3830 IFD=C0GOTO3870
3840 IFI=C1THENPRINT"";
3850 PRINT"":GOTO3910
3870 IFI=C1THENPRINT:GOTO3910
3890 IFER=C1THENPRINT"":GOTO3910
3900 PRINT""
3910 NEXT
3920 FORI=C1TO5:PRINTZ$;:IFC=C1THENPRINT"";:GOTO3970
3930 IFEL=C1THENPRINT"";:GOTO3970
3940 IFI=C1THENPRINT"";:GOTO3970
3950 IFI>4THENPRINT"";:GOTO3970
3960 PRINT"";
3970 IFE=C0THENPRINT"";:GOTO3990
3980 PRINT"";
3990 IFD=C1THENPRINT"":GOTO4040
4000 IFER=C1THENPRINT"":GOTO4040
4010 IFI=C1THENPRINT"":GOTO4040
4020 IFI>C4THENPRINT"":GOTO4040
4030 PRINT""
4040 NEXT
4050 FORI=C1TO2:PRINTZ$;:IFC=C1GOTO4100
4060 IFI<>C1THEN4080
4070 IFEL=C0THENPRINT"";:GOTO4130
4080 PRINT""LEFT$(SP$,C2−I)""LEFT$(SP$,I−C1);
4085 IFI=C1THEN4130
4090 GOTO4140
4100 IFI=C1THENPRINT"";
4110 PRINT"";
4120 IFI=C2THENPRINT"";:GOTO4140
4130 IFE=C0THENPRINT"";:GOTO4150
4140 PRINT"";
4150 IFD=C1GOTO4200
4160 IFI<>C1THEN4180
4170 IFER=C0THENPRINT"":GOTO4230
4180 PRINT""LEFT$(SP$,I−C1)""LEFT$(SP$,C2−I):GOTO4230
4200 PRINT"";:IFI=C2THENPRINT"";
4210 PRINT""
4230 NEXTI
4240 RETURN
4250 REM DISPLAY DEPTH 5
4260 PRINT"";:Z$=Z$+""
4270 PRINTZ$;:IFC=C0GOTO4290
4280 PRINT"";:GOTO4300
4290 PRINT"";
4300 IFE=C0THENPRINT"";:GOTO4320
4310 PRINT"";
4320 IFD=C0GOTO4340
4330 PRINT"":GOTO4350
4340 PRINT""
4350 FORI=C1TO3:PRINTZ$;:IFC=C1GOTO4370
4360 PRINT"";:GOTO4380
4370 PRINT"";
4380 IFE=C0THENPRINT"";:GOTO4400
4390 PRINT"";
4400 IFD=C0THENPRINT"":GOTO4420
4410 PRINT""
4420 NEXT
4430 PRINTZ$;:IFC=C1GOTO4450
4440 PRINT"";:GOTO4460
4450 PRINT"";
4460 IFE=C1THENPRINT"";:GOTO4480
4470 PRINT"";
4480 IFD=C1GOTO4500
4490 PRINT"":GOTO4510
4500 PRINT""
4510 RETURN
4520 PRINT"
4530 IFM1THENPRINT"":GOTO4560
4540 PRINT"":GOSUB1780
4550 GOSUB1140
4560 INPUT"";Z$
4570 IFZ$=""GOTO70
4580 END
4590 FORI=0TO10:FORJ=0TO19
4600 PRINTRIGHT$(""+MID$(STR$(A(J,I)),2),2)"";:NEXTJ:PRINT:NEXTI
4610 PRINT:PRINT
4620 FORJ=V−1TO0STEP−1:FORI=1TOH
4630 PRINTRIGHT$(""+MID$(STR$(B(I,J)),2),2)"";:NEXTI:PRINT:NEXTJ
READY.