home *** CD-ROM | disk | FTP | other *** search
- 100 rem tic-tac-toe
- 110 goto 560
- 120 rem x
- 130 poke m,a:poke m+4,a:poke m+41,a
- 140 poke m+43,a:poke m+82,a:poke m+121,a
- 150 poke m+123,a:poke m+160,a:poke m+164,a
- 160 return
- 170 rem o
- 180 poke m,233:poke m+4,223:poke m+160,95:poke m+164,105
- 190 for i=1 to 3
- 200 poke m+i,a:poke m+i+160,a
- 210 poke m+40*i,a:poke m+40*i+4,a
- 220 next i
- 230 poke m+82,32
- 240 return
- 250 for i=m+c to m+c+160 step 40
- 260 poke i,cc(n):poke i+1,cc(n):poke i+2,cc(n):poke i+3,cc(n):poke i+4,cc(n)
- 270 next i
- 280 return
- 290 rem tone
- 300 poke f1,42:poke f2,62
- 310 poke w,17
- 320 for d=1 to 60:next d:poke w,0
- 330 return
- 340 x=n:p(e)=x:m=s(e):on x gosub 130,130,180
- 350 gosub 250
- 360 for i=1 to 7 step 3
- 370 if p(i)<>p(i+1) then 400
- 380 if p(i)<>p(i+2) then 400
- 390 on p(i)+1 goto 400,1550,1550,1550
- 400 next i
- 410 for i=1 to 3
- 420 if p(i)<>p(i+3) then 450
- 430 if p(i)<>p(i+6) then 450
- 440 on p(i)+1 goto 450,1550,1550,1550
- 450 next i
- 460 if p(5)<>x then 490
- 470 if (p(1)=x) and (p(9)=x) then 1550
- 480 if (p(3)=x) and (p(7)=x) then 1550
- 490 for i=1 to 9
- 500 if p(i)=0 then 540
- 510 next i
- 520 print "tie game!"
- 530 goto 1590
- 540 n=abs(n-4)
- 550 return
- 560 print "[147]":poke 53281,1
- 570 w=54276:poke w,0
- 580 print tab(15)"tic-tac-toe"
- 590 for i=1 to 9:read s(i):next i
- 600 data 1114,1122,1130,1434,1442
- 610 data 1450,1754,1762,1770
- 620 print "choose one of the position numbers."
- 630 print "try to get three in a row."
- 640 poke 54296,15:f1=54273:f2=54272:c=f2
- 650 poke w+1,128:poke w+2,16
- 660 a=160:cc(1)=6:cc(3)=10
- 670 print "alternate turns with the computer."
- 680 print "[144]x gets first move."
- 690 y=3:z=1:ch=2
- 700 print "choose [144]f1 for [144]x"
- 710 print tab(8)"[144]f3 for [144]o"
- 720 get e$:if e$<>"[133]" and e$<>"[134]" then 720
- 730 if e$="[133]"then y=1:z=3
- 740 poke 198,0
- 750 print "choose [144]f1 beginner"
- 760 print tab(8)"[144]f3 intermediate"
- 770 get e$:if e$<>"[133]" and e$<>"[134]" then 770
- 780 if e$="[133]" then ch=1
- 790 print "[147]":ct=int(14*rnd(0))+2
- 800 for i=1 to 9:p(i)=0:next i
- 810 for i=1080 to 1960 step 40
- 820 poke i,a:poke i+c,ct
- 830 poke i+8,a:poke i+8+c,ct
- 840 next i
- 850 for i=1353 to 1375
- 860 poke i,a:poke i+c,ct:poke i+320,a:poke i+320+c,ct
- 870 next i
- 880 for i=1 to 9:poke s(i)+82,i+48
- 890 poke s(i)+82+c,0:next i
- 900 n=1
- 910 if ch=2 then 1040
- 920 if y=1 then 970
- 930 rem computer's move
- 940 e=int(9*rnd(0)+1):if p(e)<>0 then 940
- 950 gosub 340
- 960 rem your move
- 970 gosub 300
- 980 get e$:if e$=""then 980
- 990 if e$<"1" or e$>"9" then 980
- 1000 e=val(e$):if p(e)<>0 then 970
- 1010 gosub 340
- 1020 on ch goto 940,1060
- 1030 rem computer's move
- 1040 if y=1 then 970
- 1050 rem center position
- 1060 if p(5)=0 then e=5:goto 1520
- 1070 if p(5)=x then 1140
- 1080 rem diagonals
- 1090 if p(1)=0 and p(9)=z then e=1:goto 1520
- 1100 if p(1)=z and p(9)=0 then e=9:goto 1520
- 1110 if p(3)=0 and p(7)=z then e=3:goto 1520
- 1120 if p(3)=z and p(7)=0 then e=7:goto 1520
- 1130 rem columns
- 1140 for k=1 to 3
- 1150 if p(k)=x or p(k+3)=x or p(k+6)=x then 1200
- 1160 if p(k)+p(k+3)+p(k+6)<>2*z then 1200
- 1170 if p(k)=0 then e=k:goto 1520
- 1180 if p(k+3)=0 then e=k+3:goto 1520
- 1190 e=k+6:goto 1520
- 1200 next k
- 1210 rem rows
- 1220 for k=1 to 7 step 3
- 1230 if p(k)=x or p(k+1)=x or p(k+2)=x then 1280
- 1240 if p(k)+p(k+1)+p(k+2)<>2*z then 1280
- 1250 if p(k)=0 then e=k:goto 1520
- 1260 if p(k+1)=0 then e=k+1:goto 1520
- 1270 e=k+2:goto 1520
- 1280 next k
- 1290 rem prevent column
- 1300 for k=1 to 3
- 1310 if p(k)=z or p(k+3)=z or p(k+6)=z then 1360
- 1320 if p(k)+p(k+3)+p(k+6)<>2*x then 1360
- 1330 if p(k)=0 then e=k:goto 1520
- 1340 if p(k+3)=0 then e=k+3:goto 1520
- 1350 e=k+6:goto 1520
- 1360 next k
- 1370 rem prevent row
- 1380 for k=1 to 7 step 3
- 1390 if p(k)=z or p(k+1)=z or p(k+2)=z then 1440
- 1400 if p(k)+p(k+1)+p(k+2)<>2*x then 1440
- 1410 if p(k)=0 then e=k:goto 1520
- 1420 if p(k+1)=0 then e=k+1:goto 1520
- 1430 e=k+2:goto 1520
- 1440 next k
- 1450 if p(5)=z then 1500
- 1460 if p(1)=0 and p(9)=x then e=1:goto 1520
- 1470 if p(1)=x and p(9)=0 then e=9:goto 1520
- 1480 if p(3)=0 and p(7)=x then e=3:goto 1520
- 1490 if p(3)=x and p(7)=0 then e=7:goto 1520
- 1500 goto 940
- 1510 rem
- 1520 gosub 340
- 1530 goto 970
- 1540 rem game over
- 1550 if x<>y then 1580
- 1560 print "you win!!!"
- 1570 goto 1590
- 1580 print "computer wins!!"
- 1590 for i=1 to 20
- 1600 poke f1,int(60*rnd(0)+30)
- 1610 poke f2,int(200*rnd(0)+10)
- 1620 gosub 310
- 1630 next i
- 1640 print "try again? (y/n)";
- 1650 get e$:if e$="n" then 1690
- 1660 if e$<>"y" then 1650
- 1670 clr
- 1680 goto 560
- 1690 print "[147]"
- 1700 end
-