Pristine Ack-5.5
[Ack-5.5.git] / lang / basic / test / checker.b
1 100 print "This program will play checkers. The computer us X,"
2 110 print "and you are 0. The computer will go first, -note: squares"
3 120 print "are printed in the form-(X,Y) and sq. 1.1 is the bottom left!"
4 130 print "do not attempt a double jump or your piece might just"
5 140 print "disappear (same for triple!)"
6 150 print "     Wait for the computer to move!!!!!!"
7 700 g=-1
8 800 dim r(50)
9 900 let l=-1
10 1000 dim s(10,10)
11 1100 data 1,0,1,0,0,0,-1,0,0,1,0,0,0,-1,0,-1,15
12 1200 for x=1to8
13 1300 fory=1to8
14 1400 read j
15 1500 if j=15 then 1800
16 1600 s(x,y)=j
17 1700 goto 2000
18 1800 restore
19 1900 reads(x,y)
20 2000 nexty
21 2100 nextx
22 2200 rem
23 2300 l=-1*l
24 2400 for x=1to 8
25 2500 for y=1to8
26 2600 if s(x,y)=0 then 3500
27 2700 if g>0 then 3000
28 2800 if s(x,y)>0 then 3500
29 2900 goto 3100
30 3000 if s(x,y)<0 then 3500
31 3100 if abs(s(x,y))<>1 then 3300
32 3200 gosub 4300
33 3300 if abs(s(x,y))<>2 then 3500
34 3400 gosub 6500
35 3500 if x<>8 then 3800
36 3600 if l=1 then 3800
37 3700 rem return
38 3800 nexty
39 3900 nextx
40 4000 print
41 4100 gosub 11400
42 4200 goto 2300
43 4300 for a=-1 to 1 step2
44 4400 let u=x+a
45 4500 let v=y+g
46 4600 if u<1 then 6300
47 4700 if u>8 then 6300
48 4800 if v<1 then 6300
49 4900 if v>8 then 6300
50 5000 if s(u,v) <> 0 then 5300
51 5100 gosub 9100
52 5200 goto 6300
53 5300 if s(u,v)=g then 6300
54 5400 if s(u,v)=2*g then 6300
55 5500 u=u+a
56 5600 v=v+g
57
58 5700 if u<1 then 6300
59 5800 if u>8 then 6300
60 5900 if v<1 then 6300
61 6000 if v>8 then 6300
62 6100 if s(u,v)<>0 then 6300
63 6200 gosub 9100
64 6300 next a
65 6400 return
66 6500 rem king moves
67 6600 for a=-1 to 1 step2
68 6700 forb=-1to 1step2
69 6800 u=x+a
70 6900 v=y+b
71 7000 if u<1 then 8700
72 7100 if u>8 then 8700
73 7200 if v<1 then 8700
74 7300 if v>8 then 8700
75 7400 if s(u,v)<>0 then 7700
76 7500 gosub 9100
77 7600 goto 8700
78 7700 if s(umv)=g then 8700
79 7800 if s(u,v)=2*g then 8700
80 7900 u=u+a
81 8000 v=v+b
82 8100 if u<1 then 8700
83 8200 if u>8 then 8700
84 8300 if v<1 then 8700
85 8400 if v>8 then 8700
86 8500 if s(u,v)<>0 then 8700
87 8600 gosub 9100
88 8700 next b
89 8800 next a
90 8900return
91 9000 goto 14200
92 9100 rem
93 9200 p=p+1
94 9300 if p=k then 12300
95 9400 if v<>(4.5+(3.5*g)) then 9600
96 9500 q=q+2
97 9600 if x<>(4.5-(3.5*g)) then9800
98 9700 q=q-2
99 9800 rem
100 9900 if u<>1 then 10100
101 10000 q=q+1
102 10100 if u<> 8 then 10300
103 10200 q=q+1
104 10300 for c=-1 to 1 step 2
105 10400 if s(u+c,v+g)<1 then 10800
106 10500 q=q-1
107 10600 if s(u-c,v-g) <> 0 then 10800
108 10700 q=q-1
109 10800 rem this was the evaluation section
110 10900 rem
111 11000 next c
112 11100 r(p)=q
113 11200 q=0
114 11300 return
115 11400 if p=0 then 18800
116 11500 for j=10to-10step -1
117 11600for f=1to p
118 11700 if r(f)=j then 12000
119 11800 next f
120 11900 next j
121 12000 let k=f+p
122 12100 print "retry": gosub 2300
123 12200 return
124 12300 print " I move from ("X Y") to("U;V")"
125 12400 letf=0
126 12500 p=0
127 12600 k=0
128 12700 if v<>(4.5+(3.5*g)) then 13000
129 12800 s(u,v)=s*g
130 12900 goto 13100
131 13000 let s(u,v)=s(x,y)
132 13100 let s(x,y)=0
133 13200 if(abs(x-u))<>2 then 13400
134 13300 s((x+u)/2,(y+v)/2)=0
135 13400 print "board";
136 13500 input d$
137 13600 if d$<>"yes" then 13900
138 13700 gosub 14100
139 13800 return
140 13900 gosub 15800
141 14000 return
142 14100 print
143 14200 for y=8to1step -1
144 14300 for x=1to8
145 14400 i=2*x
146 14500 if s(x,y)<>0 then14700
147 14600 print tab(i)".";
148 14700 if s(x,y)<>1 then 14900
149 14800 print tab(i)"0"
150 14900 if s(x,y)<>-1then 15100
151 15000 print tab(i)"X"
152 15100 if s(x,y)<>-2 then 15300
153 15200 print tab(i)"X";tab(I)"*"
154 15300 if s(x,y)<>2 then 15500
155 15400 print tab(i)"O";tab(I)"*"
156 15500 next x
157 15600 print
158 15700 next y
159 15800 print
160 15900 print "from";
161 16000 input e,h
162 16100 x=e
163 16200 y=h
164 16300 if s(x,y)<>0 then 16700
165 16400 print "there is no one occupying that space"
166 16500 print
167 16600 goto 15900
168 16700 print "to";
169 16800 input a,b
170 16900 x=a
171 17000 y=b
172 17100 if s(x,y)=0 then 17500
173 17200 print "that space is already occupied"
174 17300 print
175 17400 goto 16700
176 17500 rem
177 17600 s(a,b)=s(e,h)
178 17700 s(e,h)=0
179 17800 t=(4.5-(3.5*g))
180 17900 if abs(e-a)<>2 then 18100
181 18000 s((e+a)/2,(h+b)/2)=0
182 18100 if b<>t then 18300
183 18200 s(a,b)= -2*g
184 18300 for x=8to8
185 18400 for y=8to8
186 18500 return
187 18600 nexty
188 18700 next x
189 18800 print " very good, you win"
190 18900 print:print
191 19100 print "           chuck out"
192 19200 end