home *** CD-ROM | disk | FTP | other *** search
- 0 rem******** connect 4 *************** ** from scs software by djb shibley **(NULL)
- 1 poke53281,12:poke53280,12:print"[147][144]";spc(13);"connect four";spc(27);
- 2 print"by djb shibley":dimu(8,10):h$(1)="heads":h$(2)="tails"
- 3 print" press 1 or 2 for number of players[145]":getx$:n=val(x$):ifn<1orn>2then3
- 4 p$(0)="just a sec.":p$(1)="wait":p$(2)="hold":p$(3)="thinking":p$(4)="deciding"
- 5 p$(5)="computing":p$(6)="working":p$(7)="hmmm":p$(8)="well !":p$(9)="hold on"
- 35 ifn=1thenn$(1)="your turn":goto50
- 40 forj=1ton:print"player";j:n$(j)="player"+str$(j)
- 41 input"return your name ";n$(j):n$(j)=left$(n$(j),9):next
- 50 forj=1to9:c(j)=0:fori=1to7:u(i,j)=0:next:next:d=0:g=0
- 55 print"[147][144] ";:forj=1to7:print" ";
- 60 printspc(12);" ";spc(12);:next
- 65 print" ":print" ";:forj=1to9:printj;:next
- 70 print" flip to see who is first[144]":printspc((40-len(n$(1)))/2);n$(1)
- 75 print" 1-heads or 2-tails[145]":getx$:x=val(x$):ifx<1orx>2then75
- 76 print"";:forj=1to3:print" ":next
- 80 y=int(rnd(0)*2+1):printh$(y);
- 85 ifx=ythenprint" you first[145]":forj=0to2000:next:print" ":goto100
- 90 print" you lose[145]":forj=0to2500:next:print" ":goto140
- 100 g=g+1:h=1:print"":gosub500:gosub550:ifd=1then405
- 140 h=2:print"":ifn=1thenprint" ":goto200
- 145 gosub500:gosub550:ifd=1then405
- 150 goto100
- 200 g=g+1:ifg>5then225
- 205 ifg<4thenw=5:goto400
- 206 ifg=4thenifu(1,5)=1andu(1,6)=1thenw=4:goto400
- 207 ifg=4thenifu(1,5)=1thenw=6:goto400
- 208 w=int(rnd(0)*3+3.9):goto400
- 225 print"[144]";p$(rnd(0)*11);""
- 230 w=0:forj=1to9:x=c(j):ifx>6then274
- 235 ifu(x,j)=hthenifu(x-1,j)=hthenifu(x-2,j)=hthenw=j
- 240 ifu(x,j-1)=hthenifu(x-1,j-2)=hthenifu(x-2,j-3)=horu(x+2,j+1)=hthenw=j
- 245 ifu(x,j+1)=hthenifu(x-1,j+2)=hthenifu(x-2,j+3)=horu(x+2,j-1)=hthenw=j
- 250 ifu(x+2,j+1)=hthenifu(x+3,j+2)=hthenifu(x+4,j+3)=horu(x,j-1)=hthenw=j
- 260 ifu(x+2,j-1)=hthenifu(x+3,j-2)=hthenifu(x+4,j-3)=horu(x,j+1)=hthenw=j
- 265 ifx>0andx<7thenifu(x+2,j-1)=hthenifu(x+3,j-2)=hthenifu(x,j+1)=hthenw=j
- 270 ifu(x+1,j+1)=hthenifu(x+1,j+2)=hthenifu(x+1,j+3)=horu(x+1,j-1)=hthenw=j
- 272 ifu(x+1,j-1)=hthenifu(x+1,j-2)=hthenifu(x+1,j-3)=horu(x+1,j+1)=hthenw=j
- 274 next:ifw>0andh=2thend=1:goto400
- 275 ifw>0then400
- 276 ifh=2thenh=1:goto230
- 277 l=1:fork=2to8:o(k)=0:c(k)=c(k)+2:ifc(k)>7then279
- 278 u(c(k),k)=1:gosub550:u(c(k),k)=0:ifd=1thend=0:o(k)=1
- 279 c(k)=c(k)-2:next:l=0:h=2
- 280 forj=1to9:x=c(j):ifx=7then300
- 282 ifu(x,j)=hthenifu(x-1,j)=hthenifx<6thenw=j
- 284 ifu(x+1,j+1)=hthenifu(x+1,j+2)=hthenifj>1andu(x+1,j-1)=0thenw=j
- 285 ifu(x+1,j-1)=hthenifu(x+1,j-2)=hthenifj<9andu(x+1,j+1)=0thenw=j
- 286 ifu(x+1,j-1)=hthenifu(x+1,j+1)=handj>2andj<8thenw=j
- 288 ifu(x,j+1)=hthenif(u(x-1,j+2)=handx<7)or(u(x+2,j-1)=handx<6)thenw=j:j=9
- 290 ifu(x,j-1)=hthenif(u(x-1,j-2)=handx<7)or(u(x+2,j+1)=handx<6)thenw=j:j=9
- 295 ifu(x+2,j-1)=hthenifu(x+3,j-2)=hthenifx>0or(x=0andu(x+4,j-3)=0)thenw=j:j=9
- 296 ifu(x+2,j+1)=hthenifu(x+3,j+2)=hthenifx>0or(x=0andu(x+4,j+3)=0)thenw=j:j=9
- 300 next:ifh=2andw=0thenh=1:goto280
- 305 h=2:ifw>0then395
- 310 forj=3to7:x=c(j):ifx>5then325
- 315 ifu(x,j-1)=hthenifu(x,j+1)=horu(x+1,j-1)=horu(x+2,j-1)=horu(x+1,j+1)=hthenw=j
- 325 next:ifh=2andw=0thenh=1:goto310
- 330 h=2:ifw>0then400
- 390 w=int(rnd(0)*7+2):ifc(w)>6then390
- 395 ifo(w)=1then390
- 400 h=2:gosub505:ifd=0then100
- 404 print"[144]i win"
- 405 print"play another ? (y/n)[145]":getx$:ifx$<>"y"andx$<>"n"then405
- 410 ifx$="y"thenprint"[147]":goto50
- 415 goto63000
- 500 print"";n$(h);" ":print"press slot #":getx$:w=val(x$):ifw<1then500
- 505 print" ":c(w)=c(w)+1:ifc(w)>7thenprint"filled":c(w)=7:goto500
- 511 u(c(w),w)=h:print" ":print" "
- 515 print"";spc(3*w);:forj=1to8-c(w):print"";:next:print" "
- 520 return
- 550 y=0:forj=1to9:ifu(c(j),j)<>hthen590
- 555 x=c(j):ifu(x,j+1)=hthenifu(x,j+2)=hthenifu(x,j+3)=htheny=1
- 560 ifu(x,j-1)=hthenifu(x,j-2)=hthenifu(x,j-3)=horu(x,j+1)=htheny=1
- 565 ifu(x-1,j)=hthenifu(x-2,j)=hthenifu(x-3,j)=htheny=1
- 570 ifu(x-1,j-1)=hthenifu(x-2,j-2)=hthenifu(x-3,j-3)=htheny=1
- 575 ifu(x-1,j+1)=hthenifu(x-2,j+2)=hthenifu(x-3,j+3)=htheny=1
- 580 ifu(x+1,j-1)=hthenifu(x+2,j-2)=hthenifu(x+3,j-3)=horu(x-1,j+1)=htheny=1
- 585 ifu(x+1,j+1)=hthenifu(x+2,j+2)=hthenifu(x+3,j+3)=horu(x-1,j-1)=htheny=1
- 590 next:ify=0then600
- 595 ifl=0thenprint"[144]four in a row":printn$(h);" you win"
- 596 d=1:return
- 600 forj=1to9:ifc(j)>6theny=y+1
- 605 next:ify<9thenreturn
- 610 print"[144]no winner this round":d=1:return
- 63000 print"[147]load"chr$(34)"payload"chr$(34)",8":print"run"
- 63002 poke631,13:poke632,13:poke198,2:end
-