home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Run Magazine ReRun: Game Pak
/
rerun-gamepak
/
quatro
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-09-20
|
7KB
|
249 lines
100 rem four-in-a row by sol steinberg
110 dimv(7),g(7,7),n(7)
120 gosub1930
130 player=1:goto1400
140 ift=-1thenreturn
150 ifq=1thenv(c)=v(c)+100^t:ift=3thenw=c
160 ifq=-1thenv(c)=v(c)+10*100^(t-1):ift=3thenb=c
170 return
180 t=0:fori=0to3:ifg(x+i,y)=qthent=t+1:goto200
190 ifg(x+i,y)=-qthent=-1:i=3
200 nexti
210 goto140
220 forj=1to4:t=0:fori=0to3
230 ifg(c,j+i)=qthent=t+1:goto250
240 ifg(c,j+i)=-qthent=-1:i=3
250 nexti:gosub140:ift=0thenj=4
260 nextj:return
270 t=0:fori=0to3:ifg(x+i,y+i)=qthent=t+1:goto290
280 ifg(x+i,y+i)=-qthent=-1:i=3
290 nexti:goto140
300 t=0:fori=0to3:ifg(x+i,y-i)=qthent=t+1:goto320
310 ifg(x+i,y-i)=-qthent=-1:i=3
320 nexti:goto140
330 print"[144] hmm, let's see... "
340 ifmove=1ormove=0thenc=int(7*rnd(0))+1:w=0:goto1320
350 fori=1to7:v(i)=0:nexti:w=0:b=0:ifn(1)=8thenv(1)=-100:goto400
360 c=1:x=1:y=n(1):q=1:gosub180:q=-1:gosub180
370 gosub220:q=-q:gosub220
380 ifn(1)<5thengosub270:q=-q:gosub270
390 ifn(1)>3thengosub300:q=-q:gosub300
400 ifn(2)=8thenv(2)=-100:goto500
410 c=2:y=n(2):forx=1to2:gosub180:nextx
420 q=-q:forx=1to2:gosub180:nextx
430 gosub220:q=-q:gosub220
440 ifn(2)<2orn(2)>5then460
450 x=1:y=n(2)-1:gosub270:q=-q:gosub270
460 ifn(2)<5thenx=2:y=n(2):gosub270:q=-q:gosub270
470 ifn(2)>6orn(2)<3then490
480 x=1:y=n(2)+1:gosub300:q=-q:gosub300
490 ifn(2)>3thenx=2:y=n(2):gosub300:q=-q:gosub300
500 ifn(3)=8thenv(3)=-100:goto640
510 c=3:y=n(3):forx=1to3:gosub180:nextx
520 q=-q:forx=1to3:gosub180:nextx
530 gosub220:q=-q:gosub220
540 ifn(3)<3orn(3)>6then560
550 x=1:y=n(3)-2:gosub270:q=-q:gosub270
560 ifn(3)<2orn(3)>5then580
570 x=2:y=n(3)-1:gosub270:q=-q:gosub270
580 ifn(3)<5thenx=3:y=n(3):gosub270:q=-q:gosub270
590 ifn(3)<2orn(3)>5then610
600 x=1:y=n(3)+2:gosub300:q=-q:gosub300
610 ifn(3)<3orn(3)>6then630
620 x=2:y=n(3)+1:gosub300:q=-q:gosub300
630 ifn(3)>3thenx=3:y=n(3):gosub300:q=-q:gosub300
640 ifn(4)=8thenv(4)=-100:goto820
650 c=4:y=n(4):forx=1to4:gosub180:nextx
660 q=-q:forx=1to4:gosub180:nextx
670 gosub220:q=-q:gosub220
680 ifn(4)<4then700
690 x=1:y=n(4)-3:gosub270:q=-q:gosub270
700 ifn(4)<3orn(4)>6then720
710 x=2:y=n(4)-2:gosub270:q=-q:gosub270
720 ifn(4)<2orn(4)>5then740
730 x=3:y=n(4)-1:gosub270:q=-q:gosub270
740 ifn(4)<5thenx=4:y=n(4):gosub270:q=-q:gosub270
750 ifn(4)>4then770
760 x=1:y=n(4)+3:gosub300:q=-q:gosub300
770 ifn(4)<2orn(4)>5then790
780 x=2:y=n(4)+2:gosub300:q=-q:gosub300
790 ifn(4)<3orn(4)>6then810
800 x=3:y=n(4)+1:gosub300:q=-q:gosub300
810 ifn(4)>3thenx=4:y=n(4):gosub300:q=-q:gosub300
820 ifn(5)=8thenv(5)=-100:goto980
830 c=5:y=n(5):forx=2to4:gosub180:nextx
840 q=-q:forx=2to4:gosub180:nextx
850 gosub220:q=-q:gosub220
860 ifn(5)<4then880
870 x=2:y=n(5)-3:gosub270:q=-q:gosub270
880 ifn(5)<3orn(5)>6then900
890 x=3:y=n(5)-2:gosub270:q=-q:gosub270
900 ifn(5)<2orn(5)>5then920
910 x=4:y=n(5)-1:gosub270:q=-q:gosub270
920 ifn(5)>4then940
930 x=2:y=n(5)+3:gosub300:q=-q:gosub300
940 ifn(5)<2orn(5)>5then960
950 x=3:y=n(5)+2:gosub300:q=-q:gosub300
960 ifn(5)<3orn(5)>6then980
970 x=4:y=n(5)+1:gosub300:q=-q:gosub300
980 ifn(6)=8thenv(6)=-100:goto1100
990 c=6:y=n(6):forx=3to4:gosub180:nextx
1000 q=-q:forx=3to4:gosub180:nextx
1010 gosub220:q=-q:gosub220
1020 ifn(6)<4then1040
1030 x=3:y=n(6)-3:gosub270:q=-q:gosub270
1040 ifn(6)<3orn(6)>6then1060
1050 x=4:y=n(6)-2:gosub270:q=-q:gosub270
1060 ifn(6)>4then1080
1070 x=3:y=n(6)+3:gosub300:q=-q:gosub300
1080 ifn(6)<2orn(6)>5then1100
1090 x=4:y=n(6)+2:gosub300:q=-q:gosub300
1100 ifn(7)=8thenv(7)=-100:goto1170
1110 c=7:x=4:y=n(7):gosub180:q=-q:gosub180
1120 gosub220:q=-q:gosub220
1130 ifn(7)<4then1150
1140 x=4:y=n(7)-3:gosub270:q=-q:gosub270
1150 ifn(7)>4then1170
1160 x=4:y=n(7)+3:gosub300:q=-q:gosub300
1170 ifw<>0thenc=w:goto1320
1180 ifb<>0thenc=b:goto1320
1190 c=1:fori=2to7
1200 ifv(i)>v(c)thenc=i
1210 nexti
1220 ifv(c)<-90orle$="a"orn(c)=7then1320
1230 n(c)=n(c)+1:g(c,n(c))=-1:q=-1
1240 gosub2110:g(c,n(c))=0:n(c)=n(c)-1
1250 ifw=0then1270
1260 w=0:v(c)=-95:goto1190
1270 ifle$="p"then1320
1280 n(c)=n(c)+1:g(c,n(c))=1:q=1
1290 gosub2110:g(c,n(c))=0:n(c)=n(c)-1
1300 ifw=0then1320
1310 w=0:v(c)=-91:goto1190
1320 print"[144] computer plays";c
1330 print"":fori=1to15-2*n(c):print"";:nexti:printtab(c+c+10)"[144] "
1340 hf=5:gosub2440
1350 g(c,n(c))=1:n(c)=n(c)+1
1360 ifw<>0thengosub2490
1370 ifw<>0thenprint"":print" computer wins!!!":goto1830
1380 print"":move=move+1:ifmove=49then1820
1390 goto1600
1400 poke53281,5:print"[147]":gosub1870
1410 print"[147]"
1420 printtab(11)"[176][195][178][195][178][195][178][195][178][195][178][195][178][195][174]"
1430 printtab(11)"[194][215][194][215][194][215][194][215][194][215][194][215][194][215][194]"
1440 printtab(11)"[171][195][219][195][219][195][219][195][219][195][219][195][219][195][179]"
1450 printtab(11)"[194][215][194][215][194][215][194][215][194][215][194][215][194][215][194]"
1460 printtab(11)"[171][195][219][195][219][195][219][195][219][195][219][195][219][195][179]"
1470 printtab(11)"[194][215][194][215][194][215][194][215][194][215][194][215][194][215][194]"
1480 printtab(11)"[171][195][219][195][219][195][219][195][219][195][219][195][219][195][179]"
1490 printtab(11)"[194][215][194][215][194][215][194][215][194][215][194][215][194][215][194]"
1500 printtab(11)"[171][195][219][195][219][195][219][195][219][195][219][195][219][195][179]"
1510 printtab(11)"[194][215][194][215][194][215][194][215][194][215][194][215][194][215][194]"
1520 printtab(11)"[171][195][219][195][219][195][219][195][219][195][219][195][219][195][179]"
1530 printtab(11)"[194][215][194][215][194][215][194][215][194][215][194][215][194][215][194]"
1540 printtab(11)"[171][195][219][195][219][195][219][195][219][195][219][195][219][195][179]"
1550 printtab(11)"[194][215][194][215][194][215][194][215][194][215][194][215][194][215][194]"
1560 printtab(11)"[173][195][177][195][177][195][177][195][177][195][177][195][177][195][189]"
1570 printtab(11)" 1 2 3 4 5 6 7":print
1580 player=-player
1590 ifplayer=1then1700
1600 print" red, which column? [157][157]";
1610 getc$:ifc$<>""then1610
1620 getc$:ifc$<"1"orc$>"7"then1620
1630 c=val(c$):printc:ifn(c)=8thenprint"that column is full!":gosub1910:goto1600
1640 print"":fori=1to15-2*n(c):print"";:nexti:printtab(c+c+10)" "
1650 hf=25:gosub2440
1660 g(c,n(c))=-1
1670 q=-1:gosub2050:ifw=1then2280
1680 n(c)=n(c)+1
1690 print"":move=move+1:ifmove=49then1820
1700 ifop$="c"then330
1710 print"[144]black, which column? [157][157]";
1720 getc$:ifc$<>""then1720
1730 getc$:ifc$<"1"orc$>"7"then1730
1740 c=val(c$):printc:ifn(c)=8thenprint"that column is full!":gosub1910:goto1710
1750 print"":fori=1to15-2*n(c):print"";:nexti:printtab(c+c+10)"[144] "
1760 hf=5:gosub2440
1770 g(c,n(c))=1
1780 q=1:gosub2050:ifw=1then2300
1790 n(c)=n(c)+1
1800 print"":move=move+1:ifmove=49then1820
1810 goto1600
1820 print"the game is a draw. nobody wins."
1830 print" do you want to play again?"
1840 geta$:ifa$="y"then1400
1850 ifa$="n"thenprint" let's play again real soon!":end
1860 goto1840
1870 fori=1to7:n(i)=1
1880 forj=1to7:g(i,j)=0
1890 nextj,i:move=0:w=0
1900 return
1910 fori=1to1500:nexti:print"[145][145] "
1920 print" ":print"[145][145]";:return
1930 print"[147]"
1940 printtab(13)"four-in-a-row"
1950 print"do you want instructions?[145]"
1960 getop$:ifop$="y"then2320
1970 ifop$<>"n"then1960
1980 print"do you want to play against the computeror another player (c or p)?";
1990 getop$:ifop$="p"thenreturn
2000 ifop$<>"c"then1990
2010 print" computer"
2020 print"level of play - amateur, pro or world class (a,p or w)?"
2030 getle$:ifle$="a"orle$="p"orle$="w"thenreturn
2040 goto2030
2050 rem test for win before n(c) changes
2060 w=0
2070 ifn(c)<4then2110
2080 j=0:fori=0to3
2090 j=j+g(c,n(c)-i)
2100 nexti:ifj=4*qthenw=1:return
2110 j=0:fori=1to7
2120 ifg(i,n(c))=qthenj=j+1
2130 ifg(i,n(c))<>qthenj=0
2140 ifj=4thenw=1
2150 nexti:ifw=1thenreturn
2160 j=0:x=n(c)-c:fori=1to7
2170 if(x+i)<1or(x+i)>7then2210
2180 ifg(i,x+i)=qthenj=j+1
2190 ifg(i,x+i)<>qthenj=0
2200 ifj=4thenw=1
2210 nexti:ifw=1thenreturn
2220 j=0:x=n(c)+c:fori=1to7
2