home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 7 / 007.d81 / connect 4 (.txt) < prev    next >
Encoding:
Commodore BASIC  |  1985-01-01  |  3.6 KB  |  88 lines

  1. 0 rem******** connect 4 *************** ** from scs software  by djb shibley **(NULL)
  2. 1 poke53281,12:poke53280,12:print"[147][144]";spc(13);"connect four";spc(27);
  3. 2 print"by djb shibley":dimu(8,10):h$(1)="heads":h$(2)="tails"
  4. 3 print"  press 1 or 2 for number of players[145]":getx$:n=val(x$):ifn<1orn>2then3
  5. 4 p$(0)="just a sec.":p$(1)="wait":p$(2)="hold":p$(3)="thinking":p$(4)="deciding"
  6. 5 p$(5)="computing":p$(6)="working":p$(7)="hmmm":p$(8)="well !":p$(9)="hold on"
  7. 35 ifn=1thenn$(1)="your turn":goto50
  8. 40 forj=1ton:print"player";j:n$(j)="player"+str$(j)
  9. 41 input"return your name ";n$(j):n$(j)=left$(n$(j),9):next
  10. 50 forj=1to9:c(j)=0:fori=1to7:u(i,j)=0:next:next:d=0:g=0
  11. 55 print"[147][144]      ";:forj=1to7:print"                            ";
  12. 60 printspc(12);"          ";spc(12);:next
  13. 65 print"                            ":print"       ";:forj=1to9:printj;:next
  14. 70 print"       flip to see who is first[144]":printspc((40-len(n$(1)))/2);n$(1)
  15. 75 print"           1-heads or 2-tails[145]":getx$:x=val(x$):ifx<1orx>2then75
  16. 76 print"";:forj=1to3:print"                                   ":next
  17. 80 y=int(rnd(0)*2+1):printh$(y);
  18. 85 ifx=ythenprint" you first[145]":forj=0to2000:next:print"                ":goto100
  19. 90 print" you lose[145]":forj=0to2500:next:print"              ":goto140
  20. 100 g=g+1:h=1:print"":gosub500:gosub550:ifd=1then405
  21. 140 h=2:print"":ifn=1thenprint"       ":goto200
  22. 145 gosub500:gosub550:ifd=1then405
  23. 150 goto100
  24. 200 g=g+1:ifg>5then225
  25. 205 ifg<4thenw=5:goto400
  26. 206 ifg=4thenifu(1,5)=1andu(1,6)=1thenw=4:goto400
  27. 207 ifg=4thenifu(1,5)=1thenw=6:goto400
  28. 208 w=int(rnd(0)*3+3.9):goto400
  29. 225 print"[144]";p$(rnd(0)*11);""
  30. 230 w=0:forj=1to9:x=c(j):ifx>6then274
  31. 235 ifu(x,j)=hthenifu(x-1,j)=hthenifu(x-2,j)=hthenw=j
  32. 240 ifu(x,j-1)=hthenifu(x-1,j-2)=hthenifu(x-2,j-3)=horu(x+2,j+1)=hthenw=j
  33. 245 ifu(x,j+1)=hthenifu(x-1,j+2)=hthenifu(x-2,j+3)=horu(x+2,j-1)=hthenw=j
  34. 250 ifu(x+2,j+1)=hthenifu(x+3,j+2)=hthenifu(x+4,j+3)=horu(x,j-1)=hthenw=j
  35. 260 ifu(x+2,j-1)=hthenifu(x+3,j-2)=hthenifu(x+4,j-3)=horu(x,j+1)=hthenw=j
  36. 265 ifx>0andx<7thenifu(x+2,j-1)=hthenifu(x+3,j-2)=hthenifu(x,j+1)=hthenw=j
  37. 270 ifu(x+1,j+1)=hthenifu(x+1,j+2)=hthenifu(x+1,j+3)=horu(x+1,j-1)=hthenw=j
  38. 272 ifu(x+1,j-1)=hthenifu(x+1,j-2)=hthenifu(x+1,j-3)=horu(x+1,j+1)=hthenw=j
  39. 274 next:ifw>0andh=2thend=1:goto400
  40. 275 ifw>0then400
  41. 276 ifh=2thenh=1:goto230
  42. 277 l=1:fork=2to8:o(k)=0:c(k)=c(k)+2:ifc(k)>7then279
  43. 278 u(c(k),k)=1:gosub550:u(c(k),k)=0:ifd=1thend=0:o(k)=1
  44. 279 c(k)=c(k)-2:next:l=0:h=2
  45. 280 forj=1to9:x=c(j):ifx=7then300
  46. 282 ifu(x,j)=hthenifu(x-1,j)=hthenifx<6thenw=j
  47. 284 ifu(x+1,j+1)=hthenifu(x+1,j+2)=hthenifj>1andu(x+1,j-1)=0thenw=j
  48. 285 ifu(x+1,j-1)=hthenifu(x+1,j-2)=hthenifj<9andu(x+1,j+1)=0thenw=j
  49. 286 ifu(x+1,j-1)=hthenifu(x+1,j+1)=handj>2andj<8thenw=j
  50. 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
  51. 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
  52. 295 ifu(x+2,j-1)=hthenifu(x+3,j-2)=hthenifx>0or(x=0andu(x+4,j-3)=0)thenw=j:j=9
  53. 296 ifu(x+2,j+1)=hthenifu(x+3,j+2)=hthenifx>0or(x=0andu(x+4,j+3)=0)thenw=j:j=9
  54. 300 next:ifh=2andw=0thenh=1:goto280
  55. 305 h=2:ifw>0then395
  56. 310 forj=3to7:x=c(j):ifx>5then325
  57. 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
  58. 325 next:ifh=2andw=0thenh=1:goto310
  59. 330 h=2:ifw>0then400
  60. 390 w=int(rnd(0)*7+2):ifc(w)>6then390
  61. 395 ifo(w)=1then390
  62. 400 h=2:gosub505:ifd=0then100
  63. 404 print"[144]i win"
  64. 405 print"play another ? (y/n)[145]":getx$:ifx$<>"y"andx$<>"n"then405
  65. 410 ifx$="y"thenprint"[147]":goto50
  66. 415 goto63000
  67. 500 print"";n$(h);"        ":print"press slot #":getx$:w=val(x$):ifw<1then500
  68. 505 print"           ":c(w)=c(w)+1:ifc(w)>7thenprint"filled":c(w)=7:goto500
  69. 511 u(c(w),w)=h:print"         ":print"            "
  70. 515 print"";spc(3*w);:forj=1to8-c(w):print"";:next:print"  "
  71. 520 return
  72. 550 y=0:forj=1to9:ifu(c(j),j)<>hthen590
  73. 555 x=c(j):ifu(x,j+1)=hthenifu(x,j+2)=hthenifu(x,j+3)=htheny=1
  74. 560 ifu(x,j-1)=hthenifu(x,j-2)=hthenifu(x,j-3)=horu(x,j+1)=htheny=1
  75. 565 ifu(x-1,j)=hthenifu(x-2,j)=hthenifu(x-3,j)=htheny=1
  76. 570 ifu(x-1,j-1)=hthenifu(x-2,j-2)=hthenifu(x-3,j-3)=htheny=1
  77. 575 ifu(x-1,j+1)=hthenifu(x-2,j+2)=hthenifu(x-3,j+3)=htheny=1
  78. 580 ifu(x+1,j-1)=hthenifu(x+2,j-2)=hthenifu(x+3,j-3)=horu(x-1,j+1)=htheny=1
  79. 585 ifu(x+1,j+1)=hthenifu(x+2,j+2)=hthenifu(x+3,j+3)=horu(x-1,j-1)=htheny=1
  80. 590 next:ify=0then600
  81. 595 ifl=0thenprint"[144]four in a row":printn$(h);"  you win"
  82. 596 d=1:return
  83. 600 forj=1to9:ifc(j)>6theny=y+1
  84. 605 next:ify<9thenreturn
  85. 610 print"[144]no winner this round":d=1:return
  86. 63000 print"[147]load"chr$(34)"payload"chr$(34)",8":print"run"
  87. 63002 poke631,13:poke632,13:poke198,2:end
  88.