home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
8bitfiles.net/archives
/
archives.tar
/
archives
/
commodore-users-of-norman
/
CUON_06_(08-1984).d64
/
backgammon
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2019-04-13
|
7KB
|
241 lines
0 CLR:DIMP(27),H(3),S$(3),Z(3),W(3),D(3):FL=-(RND(1)>.5)
1 FORI=1TO12:P(I)=5*(I=6)+3*(I=8)-2*(I=1)-5*(I=12):P(25-I)=-P(I):NEXT
2 DATA"[146][212][160][217][146][146][165] [167][146][146][146][199][160][200][146][146][180] [170][146][146][146][194][160][221][146][146][181] [182][146][146][146][221] [194][146][146][161] [146][161][146]"
3 DATA"[146][200] [199][146][146][146][182] [146][181][146][217] [212][146][146][146][170] [146][180][146][167] [165][146][146][146][167] [146][165]"
4 S=1:O=24:P=1:A0=1:S0=1
5 DEFFNX(I)=-(I<13)-21*(I>12)
6 IFFLTHENDEFFNY(I)=-(I<13)*(3*I-1-2*(I>6))-(I>12)*(74-3*I-2*(I<19)):GOTO8
7 DEFFNY(I)=-(I<13)*(38-3*I-2*(I<7))-(I>12)*(3*I-37-2*(I>18))
8 DEFFNR(J)=31-(J=1)*(S=2)*19-(J=0)*(25*(S<3)+6*(S=3))
9 READM$:READX$:M$=M$+X$:X$="":GOTO175
10 S=2:W=1E+9:X=0:F=0:E=0:M$="":GOSUB121
11 FORI=1TO6:J=25-I:IFP(I)<-1THENX=X+1
12 IFP(J)>1THENE=E+1
13 NEXT:A=0:B=0:X=X*X:E=E*E:IFP(25)<0ANDE=36THEN58
14 FORI=1TO24:J=25-I:IFP(I)<0THENA=A-I*P(I)
15 IFP(J)>0THENB=B+I*P(J)
16 NEXT:A=A-P(25)*(24+E/5):B=B+P(0)*(24+X/5):R0=A/B:C0=A/167
17 FORI=OTO2STEP-1:L=25-I:A=0:FORJ=I-1TO1STEP-1:IFP(J)<=0THEN19
18 K=I-J:IFK<13THENA=A+PEEK(875+K)
19 NEXT:POKE827+I,INT(A*L^1.35/15):NEXT:POKE828,0
20 FORI=1TO24:L=25-I:X=PEEK(827+I):IFI>13THEN22
21 X=X+INT(PEEK(875+I)*L^1.35/15)
22 POKE851+I,X:NEXT:E0=.8/R0^.2:F0=2.3*R0^.2:B0=2/R0^1.2:IFR0>1.5THENB0=0
23 H0=.07/C0:C0=2/(1+.1*ABS(C0-1/C0)):G0=1.4*C0*C0:F5=(O<P):IFA0=2THEN26
24 T1=0:IFO<7ANDP(26)=0THEN26
25 IFR0<.85/S0^.15THEN59
26 IFF5THENB0=3:H0=1:IFO<7THENB0=0:G0=0
27 GOSUB96:IFP(25)<0ANDP(25-D(0))>1ANDP(25-D(1))>1THEN58
28 F=0
29 FORI=1TOO
30 D=0:X=I:GOTO72
31 FORJ=1TOI
32 D=1:X=J:GOTO72
33 FORK=1TOJ
34 D=2:X=K:GOTO72
35 FORL=1TOK
36 D=3:X=L:GOTO72
37 B=0:Y=0:X=0:G=0:U=0:T=0:C=827-24*(P=0):F6=(O<P):D0=140*(F5>F6)
38 FORN=1TOO:V=P(N):IFV>=0THEN42
39 Y=Y+V*V:IFF6THEN42
40 IFV=-1ANDP<NTHENX=X+PEEK(C+N):GOTO42
41 IFV<-1THENU=U+PEEK(965+N):IFN<7THENT=T+1
42 NEXT:IFX>38THENX=X+E*E
43 FORN=0TOM:A=Z(N):IFH(N)=1THENG=G+PEEK(887+A)
44 C=6*INT((A+D(N)-1)/6):IFA<=CTHENB=B+C*C-16*(C=0)
45 IFA<5ANDA>0THENY=Y+6-A
46 NEXT:IFP(0)>0THENG=G+P(0)*T^3.5
47 V=E0*X-G0*U-F0*G-H0*B+C0*Y+B0*(25-Z(M)-D(M))+D0
48 IFV<WTHENFORN=0TOM:W(N)=Z(N):NEXT:W=V:H=F:T1=T
49 GOSUB83
50 ONM+1GOTO54,53,52,51
51 NEXT:D=2:GOSUB83
52 NEXT:D=1:GOSUB83
53 NEXT:D=0:GOSUB83
54 NEXT:IFM=1ANDF=0THENF=1:GOSUB92:GOTO29
55 IFW<1E+9THENGOSUB65:GOTO135
56 IFM=0ANDF=0THENF=1:GOSUB92:GOTO29
57 M=M-1:IFM>-1THENGOSUB92:GOTO28
58 M$="CAN'T":F=1:GOSUB121:GOTO135
59 M$="DOUBLE":F=3:GOTO158
60 IFS=1THENS=3:GOTO63
61 IFP(0)>0ANDT1=6THEN58
62 S=3:M$="SHAKE":GOSUB121:GOSUB170:IFX$="D"ANDA0<3THEN112
63 GOSUB96:IFP(0)>0ANDP(D(0))<0ANDP(D(1))<0THEN58
64 GOTO128
65 FORI=0TOM:Y=W(I)
66 IFM>1THEN68
67 IFM=1ANDH=0THENGOSUB92
68 X=Y+D(I):IFY<=0THENY=27
69 GOSUB136:NEXT:RETURN
70 FORN=0TO24:IFP(N)>0THENP=N:N=24
71 NEXT:RETURN
72 IFP(X)>=0OR(P(25)<0ANDX<25)THEN80
73 G=1:Y=X-D(D):IFY<1THEN76
74 IFP(Y)>1THEN80
75 GOTO81
76 IFO>6THEN80
77 IFY=0THEN81
78 FORV=6TOX+1STEP-1:IFP(V)<0THENG=0
79 NEXT:IFGTHEN81
80 OND+1GOTO54,53,52,51
81 Z(D)=Y:GOSUB85:IFM=DTHEN37
82 OND+1GOTO31,33,35
83 X=Z(D):Y=X+D(D):IFX<=0THENX=27:P(X)=P(X)-1:GOTO88
84 IFP(X)=-1ANDH(D)=1THENP(X)=1:H(D)=0:P(0)=P(0)-1:GOSUB70:GOTO86
85 P(X)=P(X)+1
86 IFY<=0THENY=27:P(Y)=P(Y)+1
87 IFY=27THEN90
88 IFP(Y)>0THENH(D)=1:P=0:P(0)=P(0)+1:P(Y)=0
89 P(Y)=P(Y)-1
90 FORN=25TO1STEP-1:IFP(N)<0THENO=N:N=1
91 NEXT:RETURN
92 A=D(0):D(0)=D(1):D(1)=A:RETURN
93 PRINT"";:FORH=1TOQ:PRINT"";:NEXT
94 IFR=0THENRETURN
95 FORH=1TOR:PRINT"";:NEXT:RETURN
96 FORJ=0TO1:R=FNR(J):FORN=0TO2:Q=10+N:GOSUB93:L=9*(D(J)-1)+3*N+912
97 IFS=1THENPRINTS$(J+2);:GOTO99
98 PRINTS$(S);
99 FORU=0TO2:PRINTCHR$(PEEK(L+U));:NEXT:NEXT:NEXT:RETURN
100 R=19:Q=9:GOSUB93:IFA0=1THENPRINT"[164][164]"
101 R=18:IFA0>1THENR=(3-A0)*39:GOSUB93:PRINT"[164]"
102 IFA0>1THENR=(3-A0)*37
103 FORI=0TO2:Q=10+I:GOSUB93:PRINT"";:IFA0=1THENPRINT" ";
104 IFI<>1THENPRINT" ":GOTO108
105 IFS0=1THENPRINT"64 ":GOTO108
106 IFS0<9THENPRINT" ";CHR$(S0+48);" "
107 IFS0>8THENPRINTS0
108 NEXT:R=19:IFA0>1THENR=39*(3-A0)
109 Q=13:GOSUB93:IFA0=1THENPRINT"[163][163]"
110 IFA0>1THENPRINT"[163]"
111 RETURN
112 IFR0>1.6THEN117
113 IFP>OANDR0>1.2THEN117
114 F=3:M$="I ACCEPT":GOSUB121
115 GOSUB229:A0=3:S0=2*S0:GOSUB100:GOTO62
117 FORI=1TO50:GOSUB174:NEXT:RUN
121 Q=23:R=17:GOSUB93:PRINT"[146] "
122 GOSUB93:PRINTM$;:IFF=2THENPRINTI+1;
123 RETURN
124 FORN=1TO24:B=ABS(P(N)):IFB=0THEN127
125 A=1+2*(N>12):C=-(P(N)>0)
126 FORK=1TOB:Q=FNX(N)+A*K:R=FNY(N):GOSUB93:PRINTS$(C):NEXT
127 NEXT:RETURN
128 FORI=0TOM
129 F=2:M$="DIE#":GOSUB158:IFX$="S"THEN133
130 IFX$="E"THENJ=I:I=M:GOTO133
131 F=1:GOSUB216:IFF=0THEN129
132 Z(I)=X:GOSUB136
133 NEXT:IFX$="E"THEN239
134 M$="OK?":F=1:GOSUB121:GOSUB170:IFX$="N"ORX$="E"THENJ=I:GOTO239
135 FORI=0TO3:H(I)=0:NEXT:GOSUB228:S=5-S:GOTO206
136 F=0:IFX>25THENP(X)=P(X)-1:A=-1:P(Y)=P(Y)+1:GOTO149
137 C=P(X):B=ABS(C):IFX<25ANDX>0THEN139
138 Q=(1+2*(S=2))*B-20*S+61:R=22-S:GOSUB156:PRINT"";:GOTO143
139 A=1+2*(X>12):IFB>7THENQ=FNX(X)+A*(B-7):R=FNY(X)-1:GOTO141
140 Q=FNX(X)+A*B:R=FNY(X)
141 GOSUB156:IFINT(X/2)<X/2THENPRINTCHR$(18+128*FL);:GOTO143
142 PRINTCHR$(18-128*(FL=0));
143 PRINT" ":P(X)=C-SGN(C)
144 IFY=26ORY=27THENP(Y)=P(Y)+1:IFP(Y)<15THEN155
145 IFP(Y)=15THEN117
146 IFY=0THENP(0)=P(0)+1:R=19:Q=1+P(0):GOTO151
147 A=1+2*(Y>12):B=5-2*S:C=25*(S-2):IFSGN(P(Y))=BTHENP(Y)=-B:F=4:GOTO149
148 P(Y)=P(Y)-B
149 E=ABS(P(Y)):IFE>7THENQ=FNX(Y)+A*(E-7):R=FNY(Y)-1:GOTO151
150 Q=FNX(Y)+A*E:R=FNY(Y)
151 GOSUB156:PRINTS$(S-2)
152 IFF<>4THEN155
153 H(I)=1:P(C)=P(C)+B:Q=B*ABS(P(C))-(S=3)*21-(S=2):R=17+S
154 GOSUB156:PRINTS$(3-S)
155 GOSUB90:GOSUB70:RETURN
156 GOSUB93:IFS=3THENRETURN
157 U=3:FORL=1TO5:PRINTS$(U);"[215][157]";:U=5-U:GOSUB174:NEXT:RETURN
158 GOSUB121:GOSUB170:IFF=3THEN244
159 IFX$="X"ANDI=0THENGOSUB92:GOSUB228:GOSUB96:GOTO158
160 PRINTX$;
161 IFX$="S"THENZ(I)=99:RETURN
162 IFX$="B"THENX=0:Y=D(I):RETURN
163 IFX$="O"THENX=25-D(I):Y=26:RETURN
164 IFX$="E"THENRETURN
165 A=VAL(X$):GOSUB170:IFX$="E"THEN158
166 PRINTX$;
167 X=10*A+VAL(X$):IFX<PORX>24THEN158
168 Y=X+D(I):PRINTY;:IFY>24THEN158
169 RETURN
170 GETX$:X=RND(1):IFX$=""THEN170
171 IFX$="#"THENRUN
172 X=ASC(X$):IFX<48ORX>90THEN170
173 RETURN
174 FORK=1TO99:NEXT:RETURN
175 PRINT"[147]";:FORI=0TO39:PRINT"[162]";:NEXT
176 IFFLTHENPRINT" 01 02 03 04 05 06 07 08 09 10 11 12 ";:GOTO178
177 PRINT" 12 11 10 09 08 07 06 05 04 03 02 01 ";
178 FORJ=0TO13:E=J>6:IFJ<>7THEN183
179 FORK=1TO5:PRINT" [146]";:FORI=1TO13:IFI=7THENPRINT" [146]";:GOTO182
181 PRINT"[166][166][166]";
182 NEXT:PRINT" ";:NEXT
183 M=12*J:PRINT" ";
184 FORI=1TO13:IFI=7THENPRINT" ";:GOTO187
185 A=I<7:B=INT(I/2)=I/2:C=A=B:D=NOTC
186 N=(1+2*E)*M+(NOTE)*(D+7*C)+E*(157*C+163*D):PRINTMID$(M$,N,6);
187 NEXT:PRINT" ";:NEXT
188 IFFLTHENPRINT" 24 23 22 21 20 19 18 17 16 15 14 13 ";:GOTO190
189 PRINT" 13 14 15 16 17 18 19 20 21 22 23 24 ";
190 M$="":FORI=0TO39:PRINT"[162]";:NEXT:GOSUB100
191 FORK=0TO5:FORJ=0TO2:FORI=0TO2:L=9*K+3*I+J+912
192 F=(J<>1)*((I=J)*(K>1)+(I=2-J)*(K>0ANDK<>2)+(I=1)*(K=5))
193 F=F+(J=1)*(I=1)*(INT(K/2)=K/2)
194 IFFTHENPOKEL,209:GOTO196
195 POKEL,32
196 NEXT:NEXT:NEXT
197 FORI=1TO24:POKE887+I,INT(.5+I^1.35)
198 POKE965+I,INT(60/(ABS(5.7-I)+1)):NEXT
199 DATA11,12,14,15,15,17,6,6,5,3,2,3
200 FORI=1TO12:READX:POKE875+I,X:NEXT
201 S$(2)="":S$(3)="[146]"
202 IFRND(1)<.5THEN204
203 S$(2)="[146]":S$(3)=""
204 S$(0)=S$(3)+"[209]":S$(1)=S$(2)+"[209]":GOSUB124
205 M$="SHAKE":GOSUB121:GOSUB170
206 F=0:FORI=0TO1:D(I)=INT(RND(1)*6+1):NEXT
207 IFS=1THEN211
208 IFD(0)<D(1)THENGOSUB92
209 M=1:IFD(0)=D(1)THEND(2)=D(0):D(3)=D(1):M=3
210 ONS-1GOTO10,60
211 M=1:GOSUB96
212 IFD(0)=D(1)THENGOSUB228:GOTO206
213 V=(D(0)<D(1)):GOSUB100:IFVTHENGOSUB92
215 GOSUB228:V=1-V:ONVGOTO10,60
216 IFP<19THEN222
217 IFP(X)>0THEN225
218 FORJ=19TOX:IFP(J)>0THEN226
219 NEXT
220 FORJ=XTO24:IFP(J)>0THENX=J:GOTO227
221 NEXT
222 IFP(X)<=0THEN226
223 IFP(0)>0ANDX>0THEN226
224 IFP<19ANDY=26THEN226
225 IFP(Y)>=-1THENRETURN
226 F=0:RETURN
227 RETURN
228 FORJ=0TO1:R=FNR(J):FORN=0TO2:Q=10+N:GOSUB93:PRINT"[146][166][166][166]":NEXT:NEXT:RETURN
229 Q=9:ONA0GOTO230,233,236
230 R=19:GOSUB93:PRINT" "
231 R=18:FORQ=10TO12:GOSUB93:PRINT"[146][166] [146][166]":NEXT
232 R=19:GOSUB93:PRINT" ":RETURN
233 R=39:GOSUB93:PRINT" "
234 R=37:FORQ=10TO12:GOSUB93:PRINT"[146][166][166] ":NEXT:R=39
235 GOSUB93:PRINT" ":RETURN
236 R=0:GOSUB93:PRINT" "
237 FORQ=10TO12:GOSUB93:PRINT" [146][166][166]":NEXT:GOTO235
239 IFJ<1THEN128
240 FORI=J-1TO0STEP-1:Y=Z(I):X=Y+D(I):IFY=99THEN243
241 IFX>24THENX=26
242 GOSUB136:IFH(I)=1THENS=2:Y=X:X=25:GOSUB136:S=3
243 NEXT:GOTO128
244 IFX$="A"THENGOSUB229:A0=2:S0=2*S0:GOSUB100:GOTO26
245 IFX$="R"THEN117
246 GOTO158