Post by David Drake on Dec 29, 2020 9:57:03 GMT -5
I took some OLD maze code from BASIC Computer Games - 1978 and transcribed on vintage-basic.net/games.html and ported it to LB. Remember AMAZING.BAS? It creates a text maze of theoretically any size with only one path. I was able to get the file size down to 2624 characters.
1 input "Maze width and length: ";H,V
if H>1 and V>1 then 11
print "Must be greater than 1":goto 1
11 dim W(H,V),V(H,V)
cls
Q=0:Z=0:X=int(rnd(1)*H+1)
for I=1 TO H
IF I=X then 17
print ".--";:goto 18
17 print ". ";
18 next I
print "."
C=1:W(X,1)=C:C=C+1
R=X:S=1:goto 26
21 if R<>H then 24
if S<>V then 23
R=1:S=1:goto 25
23 R=1:S=S+1:goto 25
24 R=R+1
25 if W(R,S)=0 then 21
26 if R-1=0 then 53
if W(R-1,S)<>0 then 53
if S-1=0 then 39
if W(R,S-1)<>0 then 39
if R=H then 33
if W(R+1,S)<>0 then 33
X=int(rnd(1)*3+1)
if X=1 then 79
if X=2 then 82
if X=3 then 86
33 if S<>V then 34
if Z=1 then 37
Q=1:goto 35
34 if W(R,S+1)<>0 then 37
35 X=int(rnd(1)*3+1)
if X=1 then 79
if X=2 then 82
if X=3 then 91
37 X=int(rnd(1)*2+1)
if X=1 then 79
if X=2 then 82
39 if R=H then 47
if W(R+1,S)<>0 then 47
if S<>V then 42
if Z=1 then 45
Q=1:goto 43
42 if W(R,S+1)<>0 then 45
43 X=int(rnd(1)*3+1)
if X=1 then 79
if X=2 then 86
if X=3 then 91
45 X=int(rnd(1)*2+1)
if X=1 then 79
if X=2 then 86
47 if S<>V then 49
if Z=1 then 52
Q=1:goto 50
49 if W(R,S+1)<>0 then 52
50 X=int(rnd(1)*2+1)
if X=1 then 79
if X=2 then 91
52 goto 79
53 if S-1=0 then 67
if W(R,S-1)<>0 then 67
if R=H then 61
if W(R+1,S)<>0 then 61
if S<>V then 56
if Z=1 then 59
Q=1:goto 57
56 if W(R,S+1)<>0 then 59
57 X=int(rnd(1)*3+1)
if X=1 then 82
if X=2 then 86
if X=3 then 91
59 X=int(rnd(1)*2+1)
if X=1 then 82
if X=2 then 86
61 if S<>V then 63
if Z=1 then 66
Q=1:goto 64
63 if W(R,S+1)<>0 then 66
64 X=int(rnd(1)*2+1)
if X=1 then 82
if X=2 then 91
66 goto 82
67 if R=H then 74
if W(R+1,S)<>0 then 74
if S<>V then 70
if Z=1 then 73
Q=1:goto 83
70 if W(R,S+1)<>0 then 73
X=int(rnd(1)*2+1)
if X=1 then 86
if X=2 then 91
73 goto 86
74 if S<>V then 76
if Z=1 then 78
Q=1:goto 77
76 if W(R,S+1)<>0 then 78
77 goto 91
78 goto 100
79 W(R-1,S)=C
C=C+1:V(R-1,S)=2:R=R-1
if C=H*V+1 then 101
Q=0:goto 26
82 W(R,S-1)=C
83 C=C+1
V(R,S-1)=1:S=S-1:if C=H*V+1 then 101
Q=0:goto 26
86 W(R+1,S)=C
C=C+1:if V(R,S)=0 then 88
V(R,S)=3:goto 89
88 V(R,S)=2
89 R=R+1
if C=H*V+1 then 101
goto 53
91 if Q=1 then 96
W(R,S+1)=C:C=C+1:if V(R,S)=0 then 94
V(R,S)=3:goto 95
94 V(R,S)=1
95 S=S+1:if C=H*V+1 then 101
goto 26
96 Z=1
if V(R,S)=0 then 98
V(R,S)=3:Q=0:goto 100
98 V(R,S)=1:Q=0:R=1:S=1:goto 25
100 goto 21
101 for J=1 TO V
print "I";
for I=1 TO H
if V(I,J)<2 then 103
print " ";
goto 104
103 print " I";
104 next I
print
for I=1 TO H
if V(I,J)=0 then 106
if V(I,J)=2 then 106
print ": ";
goto 107
106 print ":--";
107 next I
print "."
next J
end