home *** CD-ROM | disk | FTP | other *** search
- 10 rem basic maze program
- 100 poke 53280,0:poke 53281,11
- 110 print"[147][205]aze [208]rogram"
- 120 print"[183][183][183][183][183][183][183][183][183][183][183][183]"
- 130 print"[212]his is a [194][193][211][201][195] equivalent of the"
- 140 print"machine code maze generator. [193]lthough"
- 150 print" not identical, it uses a very similar"
- 160 print" algorithm and method of storing data."
- 170 print"[196]imensions:"
- 180 print"[205]aximum: 18,10"
- 190 print"[205]inimum: 1,1"
- 200 print"[214]isible [195]haracters 33-132, 161-255"
- 210 input"[196]imensions: 18,10[157][157][157][157][157][157][157]";h,v
- 215 if h<1 or v<1 or h>18 or v>10 then print"[196]imensions out of range !":goto 210
- 220 input"[195]haracter: 255[157][157][157][157][157]";c
- 225 if c<33 or c>255 then print" [212]ry a different character.":goto 220
- 230 print"[147][212]his will take around";int(h*v/3+1);"seconds."
- 240 ti$="000000"
- 997 :
- 998 :
- 999 rem main loop
- 1000 gosub 10000 : rem setup variables
- 1010 gosub 5000 : rem print time
- 1020 if dc>0 then gosub 2010
- 1030 m%(r,s)=m%(r,s) or 4
- 1040 dc=t(rnd(1)*t)
- 1050 if t>0 then p=p+1:p%(p)=dc
- 1060 if dc=1 then s=s-1:m%(r,s)=m%(r,s) or 1:goto 1110
- 1070 if dc=2 then m%(r,s)=m%(r,s) or 1:s=s+1:goto 1110
- 1080 if dc=3 then r=r-1:m%(r,s)=m%(r,s) or 2:goto 1110
- 1090 if dc=4 then m%(r,s)=m%(r,s) or 2:r=r+1:goto 1110
- 1100 gosub 3010:goto 1120: rem deadend!
- 1110 m%(r,s)=m%(r,s) or o
- 1120 if p>0 then 1010
- 1130 gosub 4010: rem finished, print out board.
- 1140 poke 198,0: rem clear keyboard
- 1150 get k$:if k$="" then 1150
- 1160 run
- 1999 :
- 2000 rem check available directions
- 2010 t(0)=0:t=0
- 2020 if s>0 then if m%(r,s-1)=0 then t(t)=1:t=t+1
- 2030 if s<v then if m%(r,s+1)=0 then t(t)=2:t=t+1
- 2040 if r>0 then if m%(r-1,s)=0 then t(t)=3:t=t+1
- 2050 if r<h then if m%(r+1,s)=0 then t(t)=4:t=t+1
- 2060 return
- 2999 :
- 3000 rem backtrack thru maze
- 3010 g=1
- 3020 q=p%(p):gosub 5000 : rem repeat...
- 3030 if q=1 then s=s+1 : rem down
- 3040 if q=2 then s=s-1 : rem up
- 3050 if q=3 then r=r+1 : rem right
- 3060 if q=4 then r=r-1 :rem left
- 3070 gosub 2010
- 3080 p=p-1:if p=0 then g=0
- 3090 if t>0 then g=0
- 3100 if g then 3020 : rem until g=0
- 3110 return
- 3999 :
- 4000 rem print maze
- 4010 m%(h,v)=m%(h,v) or 1
- 4020 print"[147]":gosub 5000
- 4030 printc$;" ";
- 4040 for i=1 to h:printc$;c$;:next:printc$
- 4050 for j=0 to v
- 4060 print c$;
- 4070 for i=0 to h
- 4080 if m%(i,j) and 2 then print" ";:goto 4100
- 4090 print" ";c$;
- 4100 next i:print
- 4110 for i=0 to h
- 4120 if m%(i,j) and 1 then printc$;" ";:goto 4140
- 4130 printc$;c$;
- 4140 next i:print c$
- 4150 next j
- 4160 return
- 5000 print"[212]ime:";ti$
- 5010 return
- 10000 dim p%((h+1)*(v+1)),m%(h,v),t%(3)
- 10010 dc=1:c$=chr$(c)
- 10020 return
- 20000 rem variables
- 20010 rem m%(h,v)-maze data
- 20020 rem p%(p) -maze movements
- 20030 rem p -position in p%(-)
- 20040 rem h,v -horiz vert dimensions
- 20050 rem r,s -position in m%(-,-)
- 20060 rem i,j -loop counters
- 20070 rem c$ -character
- 20080 rem dc -direction chosen 1-4
- 20090 rem t -no. of different
- 20100 rem directions
- 20110 rem t(t) -different directions
- 20120 rem available
-