home *** CD-ROM | disk | FTP | other *** search
/ Run Magazine ReRun: Strategy Games 2 / rerun-strategygamesII.d64 / quattro (.txt) < prev    next >
Encoding:
Commodore BASIC  |  1989-01-01  |  7.5 KB  |  279 lines

  1. 2 printchr$(147)"would you like instructions (y/n)?
  2. 4 [161] a$: [139] a$[179][177] "y" [175] a$[179][177]"n" [167] 4
  3. 6 [139] a$[178]"n" [167] 56
  4. 8 [153]"instructions on screen or printer (s/p)?
  5. 10 get b$: if b$<> "s" and b$<>"p" then 10
  6. 12 if b$="s"then  d=3
  7. 14 if b$="p" then d=4
  8. 16 open d,d
  9. 18 print#d,"
  10. 20 [152]d,"four-in-a-row by sol steinberg
  11. 22 print#d,"
  12. 24 [152]d,"run it right: c-64
  13. 26 print#d,"
  14. 28 [152]d,"four-in-a-row, a computer version of
  15. 30 print#d,"connect four, resembles tic-tac-toe but
  16. 32 [152]d,"is more difficult, because the playing
  17. 34 print#d,"board is seven-by-seven. you can play
  18. 36 [152]d,"against the computer at your choice of
  19. 38 print#d,"three difficulty levels.
  20. 40 [152]d,"
  21. 42 print#d,"to take a turn, choose a column and the
  22. 44 [152]d,"computer fills the lowest unoccupied
  23. 46 print#d,"square in that column with your color.
  24. 48 [152]d,"you win when you are the first one to
  25. 50 print#d,"occupy four squares in a line, horizon-
  26. 52 [152]d,"tally, vertically or diagonally.
  27. 54 print#d,"":closed
  28. 56 print"press any key to begin the program..."
  29. 58 get e$:if e$="" then 58
  30. 60 clr
  31. 62 rem four-in-a row by sol steinberg
  32. 64 dimv(7),g(7,7),n(7)
  33. 66 gosub428
  34. 68 player=1:goto322
  35. 70 ift=-1thenreturn
  36. 72 ifq=1thenv(c)=v(c)+100^t:ift=3thenw=c
  37. 74 ifq=-1thenv(c)=v(c)+10*100^(t-1):ift=3thenb=c
  38. 76 return
  39. 78 t=0:fori=0to3:ifg(x+i,y)=qthent=t+1:goto82
  40. 80 ifg(x+i,y)=-qthent=-1:i=3
  41. 82 nexti
  42. 84 goto70
  43. 86 forj=1to4:t=0:fori=0to3
  44. 88 ifg(c,j+i)=qthent=t+1:goto92
  45. 90 ifg(c,j+i)=-qthent=-1:i=3
  46. 92 nexti:gosub70:ift=0thenj=4
  47. 94 nextj:return
  48. 96 t=0:fori=0to3:ifg(x+i,y+i)=qthent=t+1:goto100
  49. 98 ifg(x+i,y+i)=-qthent=-1:i=3
  50. 100 nexti:goto70
  51. 102 t=0:fori=0to3:ifg(x+i,y-i)=qthent=t+1:goto106
  52. 104 ifg(x+i,y-i)=-qthent=-1:i=3
  53. 106 nexti:goto70
  54. 108 print"[144] hmm, let's see... "
  55. 110 ifmove=1ormove=0thenc=int(7*rnd(0))+1:w=0:goto306
  56. 112 fori=1to7:v(i)=0:nexti:w=0:b=0:ifn(1)=8thenv(1)=-100:goto122
  57. 114 c=1:x=1:y=n(1):q=1:gosub78:q=-1:gosub78
  58. 116 gosub86:q=-q:gosub86
  59. 118 ifn(1)<5thengosub96:q=-q:gosub96
  60. 120 ifn(1)>3thengosub102:q=-q:gosub102
  61. 122 ifn(2)=8thenv(2)=-100:goto142
  62. 124 c=2:y=n(2):forx=1to2:gosub78:nextx
  63. 126 q=-q:forx=1to2:gosub78:nextx
  64. 128 gosub86:q=-q:gosub86
  65. 130 ifn(2)<2orn(2)>5then134
  66. 132 x=1:y=n(2)-1:gosub96:q=-q:gosub96
  67. 134 ifn(2)<5thenx=2:y=n(2):gosub96:q=-q:gosub96
  68. 136 ifn(2)>6orn(2)<3then140
  69. 138 x=1:y=n(2)+1:gosub102:q=-q:gosub102
  70. 140 ifn(2)>3thenx=2:y=n(2):gosub102:q=-q:gosub102
  71. 142 ifn(3)=8thenv(3)=-100:goto170
  72. 144 c=3:y=n(3):forx=1to3:gosub78:nextx
  73. 146 q=-q:forx=1to3:gosub78:nextx
  74. 148 gosub86:q=-q:gosub86
  75. 150 ifn(3)<3orn(3)>6then154
  76. 152 x=1:y=n(3)-2:gosub96:q=-q:gosub96
  77. 154 ifn(3)<2orn(3)>5then158
  78. 156 x=2:y=n(3)-1:gosub96:q=-q:gosub96
  79. 158 ifn(3)<5thenx=3:y=n(3):gosub96:q=-q:gosub96
  80. 160 ifn(3)<2orn(3)>5then164
  81. 162 x=1:y=n(3)+2:gosub102:q=-q:gosub102
  82. 164 ifn(3)<3orn(3)>6then168
  83. 166 x=2:y=n(3)+1:gosub102:q=-q:gosub102
  84. 168 ifn(3)>3thenx=3:y=n(3):gosub102:q=-q:gosub102
  85. 170 ifn(4)=8thenv(4)=-100:goto206
  86. 172 c=4:y=n(4):forx=1to4:gosub78:nextx
  87. 174 q=-q:forx=1to4:gosub78:nextx
  88. 176 gosub86:q=-q:gosub86
  89. 178 ifn(4)<4then182
  90. 180 x=1:y=n(4)-3:gosub96:q=-q:gosub96
  91. 182 ifn(4)<3orn(4)>6then186
  92. 184 x=2:y=n(4)-2:gosub96:q=-q:gosub96
  93. 186 ifn(4)<2orn(4)>5then190
  94. 188 x=3:y=n(4)-1:gosub96:q=-q:gosub96
  95. 190 ifn(4)<5thenx=4:y=n(4):gosub96:q=-q:gosub96
  96. 192 ifn(4)>4then196
  97. 194 x=1:y=n(4)+3:gosub102:q=-q:gosub102
  98. 196 ifn(4)<2orn(4)>5then200
  99. 198 x=2:y=n(4)+2:gosub102:q=-q:gosub102
  100. 200 ifn(4)<3orn(4)>6then204
  101. 202 x=3:y=n(4)+1:gosub102:q=-q:gosub102
  102. 204 ifn(4)>3thenx=4:y=n(4):gosub102:q=-q:gosub102
  103. 206 ifn(5)=8thenv(5)=-100:goto238
  104. 208 c=5:y=n(5):forx=2to4:gosub78:nextx
  105. 210 q=-q:forx=2to4:gosub78:nextx
  106. 212 gosub86:q=-q:gosub86
  107. 214 ifn(5)<4then218
  108. 216 x=2:y=n(5)-3:gosub96:q=-q:gosub96
  109. 218 ifn(5)<3orn(5)>6then222
  110. 220 x=3:y=n(5)-2:gosub96:q=-q:gosub96
  111. 222 ifn(5)<2orn(5)>5then226
  112. 224 x=4:y=n(5)-1:gosub96:q=-q:gosub96
  113. 226 ifn(5)>4then230
  114. 228 x=2:y=n(5)+3:gosub102:q=-q:gosub102
  115. 230 ifn(5)<2orn(5)>5then234
  116. 232 x=3:y=n(5)+2:gosub102:q=-q:gosub102
  117. 234 ifn(5)<3orn(5)>6then238
  118. 236 x=4:y=n(5)+1:gosub102:q=-q:gosub102
  119. 238 ifn(6)=8thenv(6)=-100:goto262
  120. 240 c=6:y=n(6):forx=3to4:gosub78:nextx
  121. 242 q=-q:forx=3to4:gosub78:nextx
  122. 244 gosub86:q=-q:gosub86
  123. 246 ifn(6)<4then250
  124. 248 x=3:y=n(6)-3:gosub96:q=-q:gosub96
  125. 250 ifn(6)<3orn(6)>6then254
  126. 252 x=4:y=n(6)-2:gosub96:q=-q:gosub96
  127. 254 ifn(6)>4then258
  128. 256 x=3:y=n(6)+3:gosub102:q=-q:gosub102
  129. 258 ifn(6)<2orn(6)>5then262
  130. 260 x=4:y=n(6)+2:gosub102:q=-q:gosub102
  131. 262 ifn(7)=8thenv(7)=-100:goto276
  132. 264 c=7:x=4:y=n(7):gosub78:q=-q:gosub78
  133. 266 gosub86:q=-q:gosub86
  134. 268 ifn(7)<4then272
  135. 270 x=4:y=n(7)-3:gosub96:q=-q:gosub96
  136. 272 ifn(7)>4then276
  137. 274 x=4:y=n(7)+3:gosub102:q=-q:gosub102
  138. 276 ifw<>0thenc=w:goto306
  139. 278 ifb<>0thenc=b:goto306
  140. 280 c=1:fori=2to7
  141. 282 ifv(i)>v(c)thenc=i
  142. 284 nexti
  143. 286 ifv(c)<-90orle$="a"orn(c)=7then306
  144. 288 n(c)=n(c)+1:g(c,n(c))=-1:q=-1
  145. 290 gosub464:g(c,n(c))=0:n(c)=n(c)-1
  146. 292 ifw=0then296
  147. 294 w=0:v(c)=-95:goto280
  148. 296 ifle$="p"then306
  149. 298 n(c)=n(c)+1:g(c,n(c))=1:q=1
  150. 300 gosub464:g(c,n(c))=0:n(c)=n(c)-1
  151. 302 ifw=0then306
  152. 304 w=0:v(c)=-91:goto280
  153. 306 print"[144]  computer plays";c
  154. 308 print"":fori=1to15-2*n(c):print"";:nexti:printtab(c+c+10)"[144] "
  155. 310 hf=5:gosub530
  156. 312 g(c,n(c))=1:n(c)=n(c)+1
  157. 314 ifw<>0thengosub540
  158. 316 ifw<>0thenprint"":print"  computer wins!!!":goto408
  159. 318 print"":move=move+1:ifmove=49then406
  160. 320 goto362
  161. 322 poke53281,5:print"[147]":gosub416
  162. 324 print"[147]"
  163. 326 printtab(11)"[176][195][178][195][178][195][178][195][178][195][178][195][178][195][174]"
  164. 328 printtab(11)"[194][215][194][215][194][215][194][215][194][215][194][215][194][215][194]"
  165. 330 printtab(11)"[171][195][219][195][219][195][219][195][219][195][219][195][219][195][179]"
  166. 332 printtab(11)"[194][215][194][215][194][215][194][215][194][215][194][215][194][215][194]"
  167. 334 printtab(11)"[171][195][219][195][219][195][219][195][219][195][219][195][219][195][179]"
  168. 336 printtab(11)"[194][215][194][215][194][215][194][215][194][215][194][215][194][215][194]"
  169. 338 printtab(11)"[171][195][219][195][219][195][219][195][219][195][219][195][219][195][179]"
  170. 340 printtab(11)"[194][215][194][215][194][215][194][215][194][215][194][215][194][215][194]"
  171. 342 printtab(11)"[171][195][219][195][219][195][219][195][219][195][219][195][219][195][179]"
  172. 344 printtab(11)"[194][215][194][215][194][215][194][215][194][215][194][215][194][215][194]"
  173. 346 printtab(11)"[171][195][219][195][219][195][219][195][219][195][219][195][219][195][179]"
  174. 348 printtab(11)"[194][215][194][215][194][215][194][215][194][215][194][215][194][215][194]"
  175. 350 printtab(11)"[171][195][219][195][219][195][219][195][219][195][219][195][219][195][179]"
  176. 352 printtab(11)"[194][215][194][215][194][215][194][215][194][215][194][215][194][215][194]"
  177. 354 printtab(11)"[173][195][177][195][177][195][177][195][177][195][177][195][177][195][189]"
  178. 356 printtab(11)" 1 2 3 4 5 6 7":print
  179. 358 player=-player
  180. 360 ifplayer=1then382
  181. 362 print"  red, which column?  [157][157]";
  182. 364 getc$:ifc$<>""then364
  183. 366 getc$:ifc$<"1"orc$>"7"then366
  184. 368 c=val(c$):printc:ifn(c)=8thenprint"that column is full!":gosub424:goto362
  185. 370 print"":fori=1to15-2*n(c):print"";:nexti:printtab(c+c+10)" "
  186. 372 hf=25:gosub530
  187. 374 g(c,n(c))=-1
  188. 376 q=-1:gosub452:ifw=1then498
  189. 378 n(c)=n(c)+1
  190. 380 print"":move=move+1:ifmove=49then406
  191. 382 ifop$="c"then108
  192. 384 print"[144]black, which column?  [157][157]";
  193. 386 getc$:ifc$<>""then386
  194. 388 getc$:ifc$<"1"orc$>"7"then388
  195. 390 c=val(c$):printc:ifn(c)=8thenprint"that column is full!":gosub424:goto384
  196. 392 print"":fori=1to15-2*n(c):print"";:nexti:printtab(c+c+10)"[144] "
  197. 394 hf=5:gosub530
  198. 396 g(c,n(c))=1
  199. 398 q=1:gosub452:ifw=1then502
  200. 400 n(c)=n(c)+1
  201. 402 print"":move=move+1:ifmove=49then406
  202. 404 goto362
  203. 406 print"the game is a draw. nobody wins."
  204. 408 print"   do you want to play again?"
  205. 410 geta$:ifa$="y"then322
  206. 412 ifa$="n"thenprint"   let's play again real soon!":end
  207. 414 goto410
  208. 416 fori=1to7:n(i)=1
  209. 418 forj=1to7:g(i,j)=0
  210. 420 nextj,i:move=0:w=0
  211. 422 return
  212. 424 fori=1to1500:nexti:print"[145][145]                                    "
  213. 426 print"                                  ":print"[145][145]";:return
  214. 428 print"[147]"
  215. 430 printtab(13)"four-in-a-row"
  216. 432 print"do you want instructions?[145]"
  217. 434 getop$:ifop$="y"then506
  218. 436 ifop$<>"n"then434
  219. 438 print"do you want to play against the computeror another player (c or p)?";
  220. 440 getop$:ifop$="p"thenreturn
  221. 442 ifop$<>"c"then440
  222. 444 print"  computer"
  223. 446 print"level of play - amateur, pro or world   class (a,p or w)?"
  224. 448 getle$:ifle$="a"orle$="p"orle$="w"thenreturn
  225. 450 goto448
  226. 452 rem test for win before n(c) changes
  227. 454 w=0
  228. 456 ifn(c)<4then464
  229. 458 j=0:fori=0to3
  230. 460 j=j+g(c,n(c)-i)
  231. 462 nexti:ifj=4*qthenw=1:return
  232. 464 j=0:fori=1to7
  233. 466 ifg(i,n(c))=qthenj=j+1
  234. 468 ifg(i,n(c))<>qthenj=0
  235. 470 ifj=4thenw=1
  236. 472 nexti:ifw=1thenreturn
  237. 474 j=0:x=n(c)-c:fori=1to7
  238. 476 if(x+i)<1or(x+i)>7then484
  239. 478 ifg(i,x+i)=qthenj=j+1
  240. 480 ifg(i,x+i)<>qthenj=0
  241. 482 ifj=4thenw=1
  242. 484 nexti:ifw=1thenreturn
  243. 486 j=0:x=n(c)+c:fori=1to7
  244. 488 if(x-i)<1or(x-i)>7then496
  245. 490 ifg(i,x-i)=qthenj=j+1
  246. 492 ifg(i,x-i)<>qthenj=0
  247. 494 ifj=4thenw=1
  248. 496 nexti:return
  249. 498 print"":print"       red wins!!!"
  250. 500 gosub540:goto408
  251. 502 print"":print"     black wins!!!"
  252. 504 gosub540:goto408
  253. 506 print"this is the same as the game called"
  254. 508 print"connect-four. it is like tic-tac-toe,"
  255. 510 print"but you must get 4 in a row. each play"
  256. 512 print"must be the lowest available row in a"
  257. 514 print"column. in the parker bros. version,"
  258. 516 print"the game is played with checkers that"
  259. 518 print"slide down a seven column device and"
  260. 520 print"the color of the checkers shows through"
  261. 522 print"holes in the device."
  262. 524 print:print"           press any key"
  263. 526 getop$:ifop$=""then526
  264. 528 print"[147]":goto438
  265. 530 so=54272:forcl=sotoso+24:pokecl,0:next
  266. 532 pokeso+24,15:pokeso+5,48:pokeso+6,248:pokeso+1,hf:pokeso+4,33
  267. 534 forcl=1to200:nextcl
  268. 536 pokeso+24,0:pokeso+4,32
  269. 538 return
  270. 540 so=54272:forcl=sotoso+24:pokecl,0:nextcl
  271. 542 pokeso+5,85:pokeso+6,85:pokeso+12,85:pokeso+13,85:pokeso+24,15
  272. 544 pokeso+4,33:pokeso+11,17
  273. 546 fori=1to6:readh1,l1,h2,l2:pokeso+1,h1:pokeso,l1:pokeso+8,h2:pokeso+7,l2
  274. 548 ifh1=50thenforcl=1to200:nextcl
  275. 550 forcl=1to100:nextcl:nexti
  276. 552 pokeso+4,32:pokeso+11,16:forcl=1to500:nextcl:restore:return
  277. 554 data25,30,18,209,33,135,25,30,42,62,31,165,50,60,37,162,42,62,31,165,50,60
  278. 556 data37,162
  279.