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