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

  1. 0 goto80
  2. 5 :
  3. 10 poke54276,.:poke54296,15:poke54273,hf:poke54272,100:poke54277,10:poke54278,10
  4. 20 poke54276,33:return
  5. 30 :
  6. 80 poke53280,3:poke53281,3
  7. 90 print"[147]"tab(11)"loadstar presents:"
  8. 95 print"      [213][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][201]"
  9. 100 print"[142]      [221][213][192][201] [192][178][192] [201] [213] [213][192][192] [201]  [201]  [213][192][201][221]"
  10. 110 print"      [221][221] [221]  [221]  [171][192][179] [171][192]  [221]  [221]  [221] [221][221]
  11. 120 [153]"      (NULL)mid$tan(NULL)  >  (NULL) mid$ mid$tantan mid$tan mid$tan mid$tan(NULL)(NULL)
  12. 125 print"      [202][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][203]"
  13. 130 print,"[149][157] commodore 64 version":printtab(19)"by
  14. 140 [153],"stop   paul formisano"
  15. 150 [129]i[178]1[164]39:e$[178]e$[170]" ":[130]:[129]j[178]1[164]39:e$[178]e$[170]"cmd":[130]:n$[178]"12345678"
  16. 160 d$[178]"":[129]i[178]1[164]20:d$[178]d$[170]"":[130]:[134]a(9,9),i4(7),j4(7):f2[178]3:b[178][171]1:w[178]1:m$[178]"(NULL)(NULL)(NULL)"
  17. 170 m$[178]" stop(NULL)print# (NULL)":[129]k[178]0[164]7:[135]i4(k),j4(k):[130]
  18. 180 [141]1440:[141]1340:p[178]6:n$(b[170]1)[178]"black":n$(w[170]1)[178]"white
  19. 190 print"[147][144]want to play the computer? (y/n) ";:gosub820
  20. 200 ifx$="n"thenprint"no":goto320
  21. 210 ifx$<>"y"thengosub820:goto200
  22. 220 print"yes":f2=3:print"[144]should i play my best? ";:gosub820
  23. 230 ifx$="n"thenprint"no":goto260
  24. 240 ifx$<>"y"thengosub820:goto230
  25. 250 print"yes":s2=2:s4=1:s5=-1.5
  26. 260 print"[144]black always goes first."
  27. 270 print"do you want black or white? [144]";:gosub820
  28. 280 ifx$="b"thenprintn$(0):n$(2)="computer":goto310
  29. 290 ifx$<>"w"thengosub820:goto280
  30. 300 printn$(2):n$(0)="computer":f2=2
  31. 310 gosub1820
  32. 320 print"[147]";:gosub680:iff2=2thenprint"         thinking...[144]"
  33. 330 t1=b:t2=w:onf2gosub920,1080,920
  34. 340 gosub1310:ifz=1then360
  35. 350 bc=bc+s1+1:wc=wc-s1:n1=n1+1:gosub680
  36. 360 ifwc=0orn1=64orz<0then410
  37. 365 gosub2100
  38. 370 t1=w:t2=b:on f2gosub920,920,1080:gosub1310:ifz=1then390
  39. 380 wc=wc+s1+1:bc=bc-s1:n1=n1+1:gosub680
  40. 390 ifbc=0orn1=64orz<0then410
  41. 400 gosub2100:goto330
  42. 410 sn=sm
  43. 420 printd$;e$:printe$:printe$:printd$;e$"[144]black has"bc"     white has"wc""
  44. 430 ifbc=wcthenprint"a tie !!":goto530
  45. 440 ifbc>wcthenprint"black";:goto460
  46. 450 print"white";
  47. 460 print" wins.":cc=bc-wc:ifcc<0thencc=-cc
  48. 470 cc=(64*cc)/n1:print"[144]that was a ";
  49. 480 ifcc<11thenprint"close game.":goto530
  50. 490 ifcc<25thenprint"good game.":goto530
  51. 500 ifcc<39thenprint"big win.":goto530
  52. 510 ifcc<53thenprint"walkover.":goto530
  53. 520 print"perfect score."
  54. 530 print"want to see replay of the game?     [157][157][157][157]";:gosub820:ifx$="n"then2000
  55. 540 print"[144]yes";:gosub1350:z8=-1:gosub1370:gosub420:z8=.
  56. 550 printd$""e$"do you want to start the game ? ";
  57. 560 gosub820:ifx$="y"thenprint"yes";:gosub1820:print"[147]";:goto180
  58. 570 print"no";:end
  59. 580 f1=0:fori1=-1to1:forj1=-1to1:ifa(i+i1,j+j1)=t2then600
  60. 590 nextj1,i1:return
  61. 600 f1=1:return
  62. 610 s1=0:fork=0to7:i5=i4(k):j5=j4(k):i6=i+i5:j6=j+j5:s3=0:ifa(i6,j6)<>t2then670
  63. 620 s3=s3+1:i6=i6+i5:j6=j6+j5:ifa(i6,j6)=t1then650
  64. 630 ifa(i6,j6)=0 then670
  65. 640 goto620
  66. 650 s1=s1+s3:ifu<>1then670
  67. 660 i6=i:j6=j:fork1=0tos3:a(i6,j6)=t1:i6=i6+i5:j6=j6+j5:nextk1
  68. 670 nextk:return
  69. 680 print"
  70. 690 x$[178]"  -tantantan(NULL)tantantan(NULL)tantantan(NULL)tantantan(NULL)tantantan(NULL)tantantan(NULL)tantantan(NULL)tantantan<"
  71. 700 [153]"    a   b   c   d   e   f   g   h"
  72. 710 [153]"  ortantantan=tantantan=tantantan=tantantan=tantantan=tantantan=tantantan=tantantan^
  73. 720 fori=1to8:printmid$(n$,i,1)" [221] ";
  74. 725 getz$:ifz$="q"then2000
  75. 730 forj=1to8:printmid$(m$,(a(i,j)+2)*2,2)" [221] ";:nextj:print:ifi<>8thenprintx$
  76. 735 getz$:ifz$="q"then2000
  77. 740 nexti:print"  [173][192][192][192][177][192][192][192][177][192][192][192][177][192][192][192][177][192][192][192][177][192][192][192][177][192][192][192][177][192][192][192][189]":ifz8thenprint""
  78. 741 ifz8=.thenprint"  to forfeit a move, type:  0 a"
  79. 742 ifz8then745
  80. 743 print"[144]black pieces:    [157][157][157][157]"bc;tab(20)"white pieces:    [157][157][157][157]"wc"[144][145][145][145][145][145]"
  81. 745 getz$:ifz$="q"then2000
  82. 746 return
  83. 750 i=-1:j=i:fork=1to2:gosub820:ifx$="q"then2000
  84. 755 g=asc(x$):if47<gandg<58theni=g-48:goto780
  85. 760 if64<gandg<74thenj=g-64:goto780
  86. 770 next:return
  87. 780 print""x$"[144] ";:next:return
  88. 790 printleft$(d$,2*(i-1)+4);spc(4*(j-1)+4);:x$=mid$(m$,(t1+2)*2,2):fork=1top
  89. 800 print"[144] [157]";:forl=1to20:next:printx$"[157]";:forl=1to20:next:next:return
  90. 810 printx$"[157]";:forl=1to20:next:next:return             <
  91. 820 forl=1to10:geta$:next
  92. 830 l=0:print" [157][146]";
  93. 840 l=l+1:getx$:ifx$<>""thenreturn
  94. 850 ifl<20then840
  95. 860 print" [157]";
  96. 870 l=l+1:getx$:ifx$<>""thenreturn
  97. 880 ifl<40then870
  98. 890 goto830
  99. 900 printd$""e$"bad move[144] input row 0-8[144] and col a-h[144]":printe$;
  100. 905 hf=30:gosub10
  101. 910 gosub1440:iff1>1thengosub680
  102. 920 rem move input subroutine
  103. 930 printd$;e$"input "n$(t1+1)"'s move <q quits>";:gosub750
  104. 940 ifi<0orj<0ori>8orj>8then900
  105. 950 ifi<>0then1000
  106. 960 g2=s2:g4=s4:g5=s5:s2=0:s4=0:s5=0:gosub1170:s2=g2:s4=g4:s5=g5:ifb1<0then980
  107. 970 printd$""e$"no forfeit allowed. "n$(t1+1)"[146] has a move."
  108. 975 hf=30:gosub10:goto1060
  109. 980 ifz=1thenz=-z:return
  110. 990 z=1:return
  111. 1000 if a(i,j)=0then1020
  112. 1010 printd$""e$"sorry...square occupied by "n$(a(i,j)+1)
  113. 1015 hf=30:gosub10:goto1060
  114. 1020 gosub580:iff1=1then1040
  115. 1030 printd$""e$"sorry...not next to "n$(t2+1)
  116. 1035 hf=30:gosub10:goto1060
  117. 1040 u=-1:gosub610:ifs1>0then1070
  118. 1050 printd$""e$"sorry...does not contain "n$(t2+1)
  119. 1060 printe$:hf=30:gosub10:goto930
  120. 1070 goto1140
  121. 1080 gosub1170:ifb1>0then1130
  122. 1090 ifs5=0then1110
  123. 1100 s5=0:goto1080
  124. 1110 printd$""e$n$(t1+1)" forfeits move":ifz=1thenz=-z
  125. 1111 ifz=.thenz=1
  126. 1115 hf=20:gosub10:hf=10:gosub10
  127. 1120 return
  128. 1130 i=i3:j=j3
  129. 1140 forl=1to37:printchr$(20);:next:ifn$(t1+1)="computer"thenhf=100:gosub10
  130. 1150 printd$""e$;n$(t1+1)" moves to "chr$(i+48)" "chr$(j+64):gosub790:z=0:u=1
  131. 1152 getz1$:ifz1$="q"then2000
  132. 1160 gosub610:printd$"[144]"e$;n$(t1+1)" takes"s1"of "n$(t2+1)"'s pieces"
  133. 1161 getz1$:ifz1$="q"then2000
  134. 1165 return
  135. 1170 b1=-1:i3=0:j3=0:fori=1to8:forj=1to8:ifa(i,j)<>0then1300
  136. 1180 gosub580:iff1=0then1300
  137. 1190 u=-1:gosub610:ifs1=0then1300
  138. 1200 if(i=1)or(i=8)thens1=s1+s2
  139. 1210 if(j=1)or(j=8)thens1=s1+s2
  140. 1220 if(i=2)or(i=7)thens1=s1+s5
  141. 1230 if(j=2)or(j=7)thens1=s1+s5
  142. 1240 if(i=3)or(i=6)thens1=s1+s4
  143. 1250 if(j=3)or(j=6)thens1=s1+s4
  144. 1260 ifs1<b1then1300
  145. 1270 ifs1>b1then1290
  146. 1280 ifrnd(1)>0.5then1300
  147. 1290 b1=s1:i3=i:j3=j
  148. 1300 nextj,i:return
  149. 1310 l=((t1+1)*64)and128:ifz<>0thenl=lor64:goto1330
  150. 1320 l=lor((((i-1)*8)and56)or(j-1and7))
  151. 1330 pokesm,l:sm=sm+1:return
  152. 1340 bc=2:wc=bc:n1=4
  153. 1350 fori=0to9:forj=0to9:a(i,j)=0:nextj,i:a(4,4)=w:a(5,5)=w:a(4,5)=b:a(5,4)=b
  154. 1360 z=0:f2=1:s2=0:s4=0:s5=0:sm=826:return
  155. 1370 print"[147][144]   replay  <press q to quit[144]>  replay"
  156. 1375 p=3:ford=826tosn-1:gosub680:l=peek(d)
  157. 1380 i=1+(land56)/8:j=1+(land7):t1=b:t2=w:ifland128thent1=w:t2=b
  158. 1390 if(land64)=0then1410
  159. 1400 printd$e$:printe$:printe$:printd$""n$(t1+1)"[146] forfeits a move":forl=1to100
  160. 1405 next:next
  161. 1410 gosub1140
  162. 1420 next
  163. 1430 goto680
  164. 1440 f1=0:print"do you want instructions? (y/n) ";:gosub820
  165. 1450 ifx$="n"thenprintchr$(13)"[145]                                   [145][145]";:return
  166. 1460 ifx$<>"y"thengosub820:goto1450
  167. 1470 print"[144]yes";:forf1=1to1000:next
  168. 1480 print"[147]othello[144] is played on an 8 x 8 grid with
  169. 1490 [153]"rows 1stop to 8stop and columns astop to hstop.
  170. 1500 print"the object of the game is to capture as"
  171. 1510 print"many of the opponent's pieces as"
  172. 1520 print"possible.  to capture pieces, place your
  173. 1530 [153]"piece so that a horizontal, vertical
  174. 1540 print"or diagonal line of your opponent's
  175. 1550 [153]"pieces is contained by yours.
  176. 1560 print"   [192][192][192][219][192][192][192][219][192][192][192][219][192][192][192][219][192][192][192][219][192][192][192]"
  177. 1570 print"      [221] [144][209] [221] [144][209] [221] [144][209] [221] [144][209] [221] [209]"
  178. 1580 print"   [192][