home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 70 / 070.d81 / b.mancala (.txt) < prev    next >
Commodore BASIC  |  2022-08-26  |  9KB  |  292 lines

  1. 100 rem@ 02
  2. 110 gosub2570:clr:poke2043,0
  3. 120 diml(12),tr(5),bo(5),nu(5),a(12),n%(5),x$(12),la$(12)
  4. 130 restore:n=0
  5. 140 gosub1950:gosub2220
  6. 150 forx=1to12
  7. 160 f=1
  8. 170 readl(x)
  9. 180 gosub850
  10. 190 next
  11. 200 forx=1to12:readx$(x):la$(x)="  "+x$(x)+" ":next
  12. 210 f=0
  13. 220 print"":printtab(7)"[159]change default board? ([153]y/[153]n)"
  14. 230 geta$:ifa$<>"n"anda$<>"y"anda$<>"q"then230
  15. 240 ifa$="q"thengosub2920:gosub2860:poke198,0:goto220
  16. 250 ifa$="n"thengosub810:goto290
  17. 260 f=1:gosub2220:gosub2470
  18. 270 forx=1to12:gosub850:next
  19. 280 f=0:goto220
  20. 290 print"[159]play against computer or human? ([153]c/[153]h)"
  21. 300 getch$:ifch$<>"c"andch$<>"h"andch$<>"q"then300
  22. 310 ifch$="q"thengosub2920:gosub2860:poke198,0:goto290
  23. 320 gosub810:ifch$="h"thench$="2":goto380
  24. 330 ifch$="c"thench$="1"
  25. 340 print""tab(5)"[159]    difficulty level? ([153]0-[153]9)   ";
  26. 350 getbo$:ifbo$<"0"orbo$>"9"andbo$<>"q"then350
  27. 360 ifbo$="q"thengosub2920:gosub2860:poke198,0:goto340
  28. 370 gosub810:printtab(10)"[159]computer is player 1":gosub1250:gosub810
  29. 380 print""tab(5)"[159]   starting player? ([153]1/[153]2)   "
  30. 390 geta$:ifa$<>"1"anda$<>"2"anda$<>"q"then390
  31. 400 ifa$="q"thengosub2920:gosub2860:poke198,0:goto380
  32. 410 pn=val(a$):ifpn<1orpn>2then380
  33. 420 goto430
  34. 430 ifpn=1thenpt=12
  35. 440 ifpn=1andch$="2"then480
  36. 450 ifpn=1andch$="1"thengosub810:print""tab(12)"computer thinking";:gosub1400
  37. 460 ifpn=1andch$="1"then600
  38. 470 ifpn=2thenpt=6
  39. 480 gosub810
  40. 490 gosub2860
  41. 500 print""tab(5)"[159]player"pn"[159]starting pocket? ":ifpn=2then560
  42. 510 ifpn=1thenprint""tab(31)"([153]0-[153]4)"
  43. 520 getx$:ifx$<>"q"thenifx$<"0"orx$>"4"then520
  44. 530 ifx$="q"thengosub2920:gosub2860:poke198,0:goto500
  45. 540 ifpn=1thenx=val(x$)+1:ifx<1orx>5then490
  46. 550 goto600
  47. 560 ifpn=2thenprint""tab(31)"[153]5-9"
  48. 570 getx$:ifx$<>"q"thenifx$<"5"orx$>"9"then570
  49. 580 ifx$="q"thengosub2920:gosub2860:poke198,0:goto500
  50. 590 ifpn=2thenx=val(x$)+2:ifx<7orx>11then480
  51. 600 ifl(x)=0thengosub810:print""tab(10)"pocket "x$(x)" empty":gosub1250:goto790
  52. 610 gosub810:print""tab(9)"[159]starting location is [158]"x$(x);:gosub2810
  53. 620 tv=l(x)
  54. 630 ifpn=1andx=6then430
  55. 640 ifpn=2andx=12then480
  56. 650 l(x)=0
  57. 660 n=0:gosub850
  58. 670 forn=1totv
  59. 680 ifx+n=ptthenx=x+1
  60. 690 ifx+n>12thenx=x-12:goto690
  61. 700 l(x+n)=l(x+n)+1
  62. 710 gosub850
  63. 720 nextn
  64. 730 x=x+tv
  65. 740 ifl(6)>29thencl=14:hi=60:pn=1:goto1800
  66. 750 ifl(12)>29thencl=6:hi=70:pn=2:goto1800
  67. 760 ifl(x)<>1then610
  68. 770 ifpn=1andx=6then420
  69. 780 ifpn=2andx=12then420
  70. 790 ifpn=1thenpn=2:goto420
  71. 800 ifpn=2thenpn=1:goto420
  72. 810 print"";
  73. 820 print"                                       "
  74. 830 print"                                       ";
  75. 840 return
  76. 850 ifx+n<6thenc=6*(x+n):r=3
  77. 860 ifx+n=6thenc=35:r=8
  78. 870 ifx+n>6andx+n<12thenc=36-((x+n-6)*6):r=14
  79. 880 ifx+n=12thenc=1:r=8
  80. 890 print"";:printtab(c);
  81. 900 forj=1tor:print"";:next
  82. 910 v=l(x+n)
  83. 920 ifv=othen1070
  84. 930 gosub1920
  85. 940 forz=1tov
  86. 950 ifz=9thenc=c+1:gosub1210
  87. 960 ifz=17thenc=c+1:gosub1210
  88. 970 ifz=25thenc=c+1:gosub1210
  89. 980 ifv=0thenv=z:goto1050
  90. 990 iff=1thenprint" ";:gosub1920:print"[146][157][209][157]";:goto1040
  91. 1000 ifz<vthenprint"";
  92. 1010 ifz=vthenprint" ";:gosub1920:print"[146][157][209][157]";
  93. 1020 ifx+n=6andpn=1thencl=7:hi=40:gosub1320:goto1050
  94. 1030 ifx+n=12andpn=2thencl=10:hi=50:gosub1320:goto1050
  95. 1040 ifz=vthengosub1260
  96. 1050 next
  97. 1060 ifv>1then1140
  98. 1070 forz=v+1totv+1
  99. 1080 print" [157]";
  100. 1090 ifz=9thenc=c+1:gosub1180
  101. 1100 ifz=17thenc=c+1:gosub1180
  102. 1110 ifz=25thenc=c+1:gosub1180
  103. 1120 ifz=tv+1then1130
  104. 1130 next
  105. 1140 print"";
  106. 1150 return
  107. 1160 data6,6,6,6,6,0,6,6,6,6,6,0
  108. 1170 data"0","1","2","3","4","t1","5","6","7","8","9","t2"
  109. 1180 print"";:printtab(c);
  110. 1190 forj=1tor:print"";:next
  111. 1200 return
  112. 1210 printtab(c);
  113. 1220 forj=1to8:print"[145]";:next
  114. 1230 ifx+n<6thenprint"";
  115. 1240 return
  116. 1250 ford=1to1500:next:return
  117. 1260 s=54272
  118. 1270 pokes+24,10:pokes+5,0:pokes+6,0:pokes,90:pokes+1,170
  119. 1280 pokes+2,50:pokes+3,50:pokes+4,129
  120. 1290 fort=1to5
  121. 1300 pokes+4,128
  122. 1310 return
  123. 1320 ifbkthen poke53280,cl
  124. 1330 s=54272
  125. 1340 pokes+24,15:pokes+5,40:pokes+6,250:pokes,100:pokes+1,hi
  126. 1350 pokes+2,50:pokes+3,50:pokes+4,65
  127. 1360 fort=1to5
  128. 1370 pokes+4,64:
  129. 1380 poke53280,11
  130. 1390 return
  131. 1400 dn=pn
  132. 1410 ifdn=1thendt=12
  133. 1420 ifdn=2thendt=6
  134. 1430 forq=1to5:bo(q)=0:ifdn=2thendn=1:dt=12
  135. 1440 forb=1to12:a(b)=l(b):next
  136. 1450 b=q
  137. 1460 vb=a(b):ifa(b)=0thenbo(q)=-1:goto1620
  138. 1470 a(b)=a(b)-vb
  139. 1480 ifdn=1andb=6thena(b)=a(b)+vb:goto1610
  140. 1490 ifdn=2andb=12thena(b)=a(b)+vb:goto1610
  141. 1500 n1=0
  142. 1510 forn1=1tovb
  143. 1520 ifb+n1=dtthenb=b+1
  144. 1530 ifb+n1>12thenb=b-12:goto1530
  145. 1540 a(b+n1)=a(b+n1)+1
  146. 1550 next
  147. 1560 b=b+vb
  148. 1570 ifa(b)<>1then1460
  149. 1580 ifdn=1andb=6then1610
  150. 1590 ifdn=1thendn=2:goto1620
  151. 1600 ifdn=2thendn=1
  152. 1610 ifdn=1thenbo(q)=val(bo$)-.5:goto1620
  153. 1620 tr(q)=a(6)+bo(q)
  154. 1630 cl=1:hi=100:gosub1320:next
  155. 1640 forq=1to5
  156. 1650 next
  157. 1660 forq=1to5:nu(q)=tr(q):next
  158. 1670 forp=1to4
  159. 1680 forw=1to4
  160. 1690 ho=nu(w)
  161. 1700 ifnu(w+1)<nu(w)thennu(w)=nu(w+1):nu(w+1)=ho
  162. 1710 next
  163. 1720 iff=0thenp=5
  164. 1730 next
  165. 1740 forq=1to5
  166. 1750 ifnu(5)=tr(q)thenx=q
  167. 1760 next
  168. 1770 print"";
  169. 1780 forq=1to5:tr(q)=0:bo(q)=0:next
  170. 1790 return
  171. 1800 poke53281,cl:print""tab(5)"                               "
  172. 1810 print""tab(5)"[159]        player"pn"wins!          "
  173. 1820 rem@ 01
  174. 1830 forcl=1to20:forhi=60to160step20:poke53281,cl+1:gosub1320:next:next
  175. 1840 rem@ 02
  176. 1850 print:poke53281,0
  177. 1860 ti$="000000":bk=1
  178. 1870 ifti<150then1870
  179. 1880 print""tab(5)"[159]        play again? ([158]y/[158]n)      ";
  180. 1890 geta$:ifa$=""then1890
  181. 1900 ifa$="y"thenrun
  182. 1910 goto2950
  183. 1920 ifx+n<7thenpoke646,7
  184. 1930 ifx+n>6thenpoke646,10
  185. 1940 return
  186. 1950 poke53280,0:poke53281,0
  187. 1960 print"[147] [176][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][192][192][192][192][192][192][192][192][192][192][192][174]"
  188. 1970 print" [221]                                    [221]"
  189. 1980 print" [221][158]             [211]trategy               [221]"
  190. 1990 print" [221][156]           [163][163][163][163][163][163][163][163][163][163][163][163]             [221]"
  191. 2000 print" [221][159]    [208]layer 1 takes all marbles from [221]"
  192. 2010 print" [221][159]one pocket on his side of the board.[221]"
  193. 2020 print" [221][159][205]oving clockwise, the player drops a[221]"
  194. 2030 print" [221][159]marble in each pocket, except in his[221]"
  195. 2040 print" [221][159]opponent's treasury.  [193]fter dropping[221]"
  196. 2050 print" [221][159]the last marble, player 1 takes the [221]"
  197. 2060 print" [221][159]marbles in that pocket and continues[221]"
  198. 2070 print" [221][159]on until the last marble in hand is [221]"
  199. 2080 print" [221][159]dropped into an empty pocket.       [221]"
  200. 2085 print" [221][159]                                    [221]"
  201. 2090 print" [221][159]    [193]t this point player 2 moves on [221]"
  202. 2100 print" [221][159]his side.  [201]f a player's last marble[221]"
  203. 2110 print" [221][159]is dropped into his treasury,he may [221]"
  204. 2120 print" [221][159]continue from any pocket on his side[221]"
  205. 2130 print" [221][159]of the board.  [212]he player with the  [221]"
  206. 2140 print" [221][159]most marbles in his treasury wins.  [221]"
  207. 2150 print" [221]                                    [221]"
  208. 2160 print" [173][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][192][192][192][192][192][192][192][192][192][192][192][189]";
  209. 2170 print"         [200]it any key to continue ";
  210. 2180 geta$:ifa$=""then2180
  211. 2190 ifa$="q"thengosub2920
  212. 2200 printchr$(142);
  213. 2210 return
  214. 2220 print"[147]";:poke53280,11:poke53281,0
  215. 2230 print"[146][147]";
  216. 2240 print"[152]     [155]       {$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}>       [154][146]     ";
  217. 2250 print"     [155] [146]    [151] [152] [155][146]    [151] [152] [155][146]    [151] [152] [155][146]    [151] [152] [155][146]     [154][146]     ";
  218. 2260 print"     [155] [146]    [151] [152] [155][146]    [151] [152] [155][146]    [151] [152] [155][146]    [151] [152] [155][146]     [154][146]     ";
  219. 2270 print"     [155] [146]    [151] [152] [155][146]    [151] [152] [155][146]    [151] [152] [155][146]    [151] [152] [155][146]     [146]  [154]   ";
  220. 2280 print"  [150]t2[154] [155] [146]    [151] [152] [15