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 >
Commodore BASIC  |  2019-04-13  |  7KB  |  241 lines

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