home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 6 / 006.d81 / othello (.txt) < prev    next >
Commodore BASIC  |  2022-08-26  |  7KB  |  319 lines

  1. 10 rem * othello
  2. 11 rem * by mark jeske
  3. 12 rem * translated and revised for
  4. 13 rem * the commodore 64 by
  5. 14 rem * donna k. woody
  6. 20 gosub10000
  7. 30 goto1000
  8. 40 :
  9. 50 rem * valid input check
  10. 60 n=0
  11. 70 ifb(i)<>0then180
  12. 80 forj=0to7
  13. 90 k=i+o(j)
  14. 100 ifb(k)<>1then170
  15. 110 k=k+o(j)
  16. 120 ifb(k)=1then110
  17. 130 ifb(k)<>2then170
  18. 140 k=k-o(j)
  19. 150 ifk=ithen170
  20. 160 n=n+1:f(n)=k:goto140
  21. 170 nextj
  22. 180 return
  23. 188 :
  24. 189 rem * computer move check
  25. 190 n=0
  26. 200 ifb(i)<>0then320
  27. 210 forj=0to7
  28. 220 k=i+o(j)
  29. 230 ifb(k)<>2then310
  30. 240 k=k+o(j)
  31. 250 ifb(k)=2then240
  32. 260 ifb(k)<>1then310
  33. 270 k=k-o(j)
  34. 280 ifk=ithen310
  35. 290 n=n+1:f(n)=k
  36. 300 goto270
  37. 310 nextj
  38. 320 return
  39. 338 :
  40. 339 rem * begin computer moves
  41. 340 poke781,19:poke782,0:sys65520
  42. 341 print"my pieces -     [157][157][157][157]"cp"  ";tab(20)"your pieces -    [157][157][157][157]"op"  "
  43. 345 if level=1thengoto600
  44. 350 ifop+cp>51andlevel=2thengoto600
  45. 360 ifop+cp>51andlevel=3thengoto700
  46. 370 forl=1to60
  47. 380 i=p(l)
  48. 390 gosub190
  49. 400 ifn>0then440
  50. 410 nextl
  51. 420 poke781,20:poke782,0:sys65520:print"i cannot move."
  52. 430 goto590
  53. 440 poke781,20:poke782,0:sys65520:print"i move to ";
  54. 450 ifi>80andi<89thenprint"a";:goto530
  55. 460 ifi>70andi<79thenprint"b";:goto530
  56. 470 ifi>60andi<69thenprint"c";:goto530
  57. 480 ifi>50andi<59thenprint"d";:goto530
  58. 490 ifi>40andi<49thenprint"e";:goto530
  59. 500 ifi>30andi<39thenprint"f";:goto530
  60. 510 ifi>20andi<29thenprint"g";:goto530
  61. 520 ifi>10andi<19thenprint"h";
  62. 530 printi-(10*int(i/10))" and flip "n" of your"
  63. 535 poke781,21:poke782,0:sys65520:print"pieces."
  64. 540 b(i)=1
  65. 550 forj=1ton
  66. 560 b(f(j))=1
  67. 570 nextj
  68. 580 gosub1450
  69. 585 forx=1to100:nextx:poke781,20:poke782,0:sys65520:forx=1to120:print" ";:next
  70. 590 goto1030
  71. 598 :
  72. 599 rem * level 1 & 2 last moves
  73. 600 x=0:y=0
  74. 610 forl=1to60
  75. 620 i=p(l)
  76. 630 gosub190
  77. 640 ifn>xthenx=n:y=i
  78. 650 nextl
  79. 660 ifx=0then420
  80. 670 i=y
  81. 680 gosub190
  82. 690 goto440
  83. 698 :
  84. 699 rem * level 3 last moves
  85. 700 x=0
  86. 710 forl=0to99:a(l)=b(l):nextl
  87. 720 forl=1to60
  88. 730 i=p(l):gosub190
  89. 740 ifn>0then780
  90. 750 nextl
  91. 760 ifx>0then930
  92. 770 goto930
  93. 780 ifx>9then930
  94. 790 x=x+1
  95. 800 r(x)=i:s(x)=n
  96. 810 b(i)=1
  97. 820 forj=1ton
  98. 830 b(f(j))=1
  99. 840 nextj
  100. 850 y=0
  101. 860 forz1=1to60
  102. 870 i=p(z1):gosub60
  103. 880 ifn>ytheny=n
  104. 890 nextz1
  105. 900 s(x)=s(x)-y
  106. 910 fork=0to99:b(k)=a(k):nextk
  107. 920 goto750
  108. 930 forl=0to99:b(l)=a(l):nextl
  109. 940 ifx<1then420
  110. 950 y=-99
  111. 960 forl=1tox
  112. 970 ifs(l)>ytheny=1
  113. 980 nextl
  114. 990 i=r(y):gosub190
  115. 991 goto440
  116. 998 :
  117. 999 rem * board display - user imput
  118. 1000 printchr$(147)
  119. 1010 gosub1720
  120. 1020 gosub1450
  121. 1030 poke781,19:poke782,0:sys65520
  122. 1040 print"my pieces -     [157][157][157][157]"cp"  ";tab(20)"your pieces -     [157][157][157][157]"op"  "
  123. 1050 forl=1to60
  124. 1060 i=p(l)
  125. 1070 gosub60
  126. 1080 ifn>0then1120
  127. 1090 nextl
  128. 1100 print"you cannot move."
  129. 1110 goto340
  130. 1120 poke781,20:poke782,0:sys65520:print"your move (l#)?[160]";
  131. 1125 poke198,0:wait198,1:getx$
  132. 1130 ifx$="l"theni=90:goto1230
  133. 1140 ifx$="a"theni=80:goto1230
  134. 1150 ifx$="b"theni=70:goto1230
  135. 1160 ifx$="c"theni=60:goto1230
  136. 1170 ifx$="d"theni=50:goto1230
  137. 1180 ifx$="e"theni=40:goto1230
  138. 1190 ifx$="f"theni=30:goto1230
  139. 1200 ifx$="g"theni=20:goto1230
  140. 1210 ifx$="h"theni=10:goto1230
  141. 1220 goto1120
  142. 1230 printx$;
  143. 1240 poke198,0:wait198,1:getx$
  144. 1250 ifval(x$)<1orval(x$)>8then1240
  145. 1260 ifi<90then1310
  146. 1270 level=val(x$)
  147. 1280 iflevel>3thenlevel=3
  148. 1290 printright$(x$,1);:print"   okay"
  149. 1300 goto1120
  150. 1310 i=i+val(x$)
  151. 1320 printright$(x$,1)
  152. 1330 gosub60
  153. 1340 ifn>0then1370
  154. 1350 print"illegal move "
  155. 1360 poke781,21:poke782,0:sys65520:goto1120
  156. 1370 print"you flipped "n" of my pieces."
  157. 1380 b(i)=2
  158. 1390 forl=1ton
  159. 1400 b(f(l))=2
  160. 1410 nextl
  161. 1420 gosub1450
  162. 1421 poke781,20:poke782,0:sys65520:forzz=1to120:print" ";:next
  163. 1425 goto340
  164. 1430 :
  165. 1440 rem * display b() on screen
  166. 1450 cp=0:op=0:x=34:y=3
  167. 1455 poke783,peek(783)and254:poke53272,21:poke204,1:poke19,0
  168. 1460 forl=89to11step-1
  169. 1470 ifb(l)=9thengoto1520
  170. 1480 ifb(l)=0thengoto1520
  171. 1490 ifb(l)=1thenpc$="[144][209]":cp=cp+1:goto1510
  172. 1500 op=op+1:pc$="[209][144]"
  173. 1510 poke781,y:poke782,x:sys65520:printpc$
  174. 1520 x=x-3
  175. 1530 ifx<7thenx=34:y=y+2:ify>17theny=3
  176. 1550 nextl
  177. 1560 ifop+cp=64then12000
  178. 1570 ifop=0orcp=0then12000
  179. 1580 return
  180. 1700 :
  181. 1710 rem * board display
  182. 1720 printchr$(147)
  183. 1730 printtab(10) "1  2  3  4  5  6  7  8"
  184. 1740 printtab(8)" [207][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208]
  185. 1750 [153][163]7)"a sgn +  +  +  +  +  +  +  +
  186. 1760 printtab(8)" [207][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208]
  187. 1770 [153][163]7)"b sgn +  +  +  +  +  +  +  +
  188. 1780 printtab(8)" [207][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208]
  189. 1790 [153][163]7)"c sgn +  +  +  +  +  +  +  +
  190. 1800 printtab(8)" [207][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208]
  191. 1810 [153][163]7)"d sgn +  +  +  +  +  +  +  +
  192. 1820 printtab(8)" [207][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208]
  193. 1830 [153][163]7)"e sgn +  +  +  +  +  +  +  +
  194. 1840 printtab(8)" [207][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208]
  195. 1850 [153][163]7)"f sgn +  +  +  +  +  +  +  +
  196. 1860 printtab(8)" [207][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208]
  197. 1870 [153][163]7)"g sgn +  +  +  +  +  +  +  +
  198. 1880 printtab(8)" [207][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208]
  199. 1890 [153][163]7)"h sgn +  +  +  +  +  +  +  +
  200. 1900 printtab(8)" [183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183]"
  201. 1910 return
  202. 9998 :
  203. 9999 rem dimension variables
  204. 10000 dimp(60),b(99),o(7),f(20),r(10),s(10),a(99)
  205. 10005 poke783,peek(783)and254:poke53272,21
  206. 10010 rem * b = board array
  207. 10020 rem * p = sequential moves
  208. 10030 rem * o = move directions
  209. 10040 rem * f = pieces flipped
  210. 10050 :
  211. 10060 rem * read data values
  212. 10070 forl=0to7
  213. 10080 reado(l)
  214. 10090 nextl
  215. 10100 forl=0to99
  216. 10110 readb(l)
  217. 10120 nextl
  218. 10130 forl=1to60
  219. 10140 readp(l)
  220. 10150 nextl
  221. 10152 forl=1to8:readv(l):next
  222. 10154 forl=1to8:readh(l):next
  223. 10160 :
  224. 10170 rem * data statements
  225. 10180 data1,9,10,11,-1,-9
  226. 10181 data-10,-11
  227. 10182 data9,9,9,9,9,9,9,9,9,9
  228. 10183 data9,0,0,0,0,0,0,0,0,9
  229. 10190 data9,0,0,0,0,0,0,0,0,9
  230. 10191 data9,0,0,0,0,0,0,0,0,9
  231. 10192 data9,0,0,0,2,1,0,0,0,9
  232. 10200 data9,0,0,0,1,2,0,0,0,9
  233. 10201 data9,0,0,0,0,0,0,0,0,9
  234. 10202 data9,0,0,0,0,0,0,0,0,9
  235. 10203 data9,0,0,0,0,0,0,0,0,9
  236. 10210 data9,9,9,9,9,9,9,9,9,9
  237. 10211 data81,88,11,18,83,86
  238. 10220 data61,68,31,38,13,16,63,66,33,36,84,85,51,58,41,48,14,15
  239. 10230 data64,65,53,56,43,46,34,35,74,75,52,57,42,47,24,25,73,76
  240. 10240 data62,67,32,37,23,26,82,87,71,78,21,28,12,17,72,77,22,27
  241. 10242 data3,5,7,9,11,13,15,17
  242. 10244 data11,14,17,20,22,25,28,31
  243. 10250 :
  244. 10260 rem * set colors
  245. 10270 poke53281,7:poke53280,12:printchr$(144)
  246. 10280 :
  247. 10290 rem * display routine
  248. 10300 printchr$(147):poke781,2:poke782,15:sys65520:print"[152]welcome to"
  249. 10310 poke781,4:poke782,13:sys65520:print"* * * * * * *"
  250. 10320 poke781,6:poke782,13:sys65520:print"*  othello  *"
  251. 10325 poke781,8:poke782,13:sys65520:print"* * * * * * *"
  252. 10330 poke781,11:poke782,15:sys65520:print"written by"
  253. 10340 poke781,13:poke782,15:sys65520:print"mark jeske"
  254. 10350 poke781,17:poke782,5:sys65520:print"[152]translated for the commodore by"
  255. 10360 poke781,19:poke782,13:sys65520:print"[154]donna k. woody"
  256. 10370 poke781,23:poke782,9:sys65520:print"[144]press any key to begin"
  257. 10380 poke198,0:wait198,1:geta$
  258. 10390 printchr$(147)
  259. 10400 poke781,2:poke782,0:sys65520:print"do you need instructions (y/n)?[160]";
  260. 10410 poke198,0:wait198,1:geta$
  261. 10420 ifa$="y"then 10470
  262. 10430 ifa$="n"thenprintchr$(147):poke53272,23:goto10640
  263. 10440 goto10400
  264. 10450 :
  265. 10460 rem * instructions & level
  266. 10470 printchr$(147):poke53272,23
  267. 10480 print"[207][212][200][197][204][204][207] is played on an 8 x 8 board.":print
  268. 10490 print"[212]he game's object is to end up with":print
  269. 10500 print"the most pieces.  [217]ou are playing white":print
  270. 10510 print"and