10REM ** NOUGHTS & CROSSES **
20REM ** Written by J.Smylie **
30REM ** v1.0 - 1987 **
40REM ** Completely rewritten **
50REM ** v2.3 - 19/02/92 **
60
70MODE1:DIM P$(9):VDU 23;8202;0;0;0;:
VDU19,0,7;0;19,2,7;0;19,3,7;0;:*LOAD $.G
RID
80VDU19,0,7;0;19,2,4;0;19,3,4;0;
90ONERROR PROCERROR
100PROCDEFINE:PROCDISPLAYCOUNTERS
110REPEAT:PROCSHOWMOVE(0):PROCSETUP:ga
meover=FALSE:PROCSTART:REPEAT
120IF mygo THEN PROCMYGO ELSE PROCYOUR
GO
130PROCTESTGAMEOVER:UNTIL gameover:PRO
CGAMEOVER:PROCPLAYAGAIN:UNTIL playagain=
FALSE
140FORT=1TO5000:NEXTT:CLS:END
150DEFPROCSETUP
160FOR V=7 TO 27 STEP 7:FOR H=6 TO 20
STEP 7:PROCCHARACTER(H,V," "):NEXT:NEXT
170FOR T=1 TO 9:P$(T)=" ":NEXT T:ENDPR
OC
180DEFPROCCHARACTER(H,V,C$)
190IF C$="X" G1$=X1$:G2$=X2$:G3$=X3$:G
4$=X2$:G5$=X1$
200IF C$="O" G1$=O1$:G2$=O2$:G3$=O2$:G
4$=O2$:G5$=O1$
210IF C$=" " G1$=O1$:G2$=O1$:G3$=O1$:G
4$=O1$:G5$=O1$
220PRINTTAB(H,V);G1$;TAB(H,V+1);G2$;TA
B(H,V+2);G3$;TAB(H,V+3);G4$;TAB(H,V+4);G
5$:ENDPROC
230DEFPROCDEFINE
240VDU 23,224,255,255,255,255,255,255,
255,255
250X1$=CHR$224+" "+CHR$224
260X2$=" "+CHR$224+" "+CHR$224+" "
270X3$=" "+CHR$224+" "
280O1$=CHR$224+CHR$224+CHR$224+CHR$224
+CHR$224
290O2$=CHR$224+" "+CHR$224
300move=0:yourcounter=0:mycounter=0:EN
DPROC
310ENDPROC
320DEFPROCYOURGO
330oldmove=move
340PRINTTAB(29,12);"COMPUTER":COLOUR13
0:COLOUR0:PRINTTAB(29,7);"OPPONENT":COLO
UR128:COLOUR3
350REPEAT:REPEAT
360PRINTTAB(29,26);"Square ?"
370move=GET:move=move-48:UNTIL move>=1
AND move<=9:UNTIL P$(move)=" ":PRINTTAB
(29,26);" "
380P$(move)=B$:newmove=move:move=oldmo
ve:PROCSHOWMOVE(0):move=newmove
390PROCCALCULATE:PROCCHARACTER(H,V,B$)
:mygo=TRUE:ENDPROC
400DEFPROCMYGO
410FORT=1TO1000:NEXTT:PRINTTAB(29,7);"
OPPONENT":COLOUR130:COLOUR0:PRINTTAB(29,
12);"COMPUTER":COLOUR128:COLOUR3
420PROCSHOWMOVE(0):PROCTHINK:P$(move)=
A$:PROCCALCULATE:PROCCHARACTER(H,V,A$):m
ygo=FALSE:ENDPROC
430DEFPROCCALCULATE
440IF move=1 THEN H=6:V=7:H2=31:V2=19
450IF move=2 THEN H=13:V=7:H2=33:V2=19
460IF move=3 THEN H=20:V=7:H2=35:V2=19
470IF move=4 THEN H=6:V=14:H2=31:V2=21
480IF move=5 THEN H=13:V=14:H2=33:V2=2
1
490IF move=6 THEN H=20:V=14:H2=35:V2=2
1
500IF move=7 THEN H=6:V=21:H2=31:V2=23
510IF move=8 THEN H=13:V=21:H2=33:V2=2
3
520IF move=9 THEN H=20:V=21:H2=35:V2=2
3
530PROCSHOWMOVE(1):ENDPROC
540DEFPROCTESTGAMEOVER
550Iwin=FALSE:youwin=FALSE
560IF P$(1)<>" " AND P$(2)<>" " AND P$
(3)<>" " AND P$(4)<>" " AND P$(5)<>" " A
ND P$(6)<>" " AND P$(7)<>" " AND P$(8)<>
" " AND P$(9)<>" " THEN gameover=TRUE
570IF FNrowof(A$) THEN Iwin=TRUE:youwi
n=FALSE:gameover=TRUE:mycounter=mycounte
r+1
580IF FNrowof(B$) THEN youwin=TRUE:Iwi
n=FALSE:gameover=TRUE:yourcounter=yourco
unter+1
590ENDPROC
600DEFPROCGAMEOVER
610IF Iwin THEN PRINTTAB(29,26);" I WI
N!"
620IF youwin THEN PRINTTAB(29,26);"YOU
WIN!"
630IF Iwin=FALSE AND youwin=FALSE THEN
PRINTTAB(29,26);" A DRAW"
640PROCDISPLAYCOUNTERS:FORT=1TO5000:NE
XTT:ENDPROC
650DEFPROCSTART
660PRINTTAB(29,26);"I START?";:YN=GET:
PRINTTAB(29,26);" "
670IF YN=78 THEN mygo=FALSE:A$="O":B$=
"X":ENDPROC
680mygo=TRUE:A$="X":B$="O":ENDPROC
690DEFFNrowof(C$)
700IF FNthree(1,2,3) THEN =TRUE
710IF FNthree(4,5,6) THEN =TRUE
720IF FNthree(7,8,9) THEN =TRUE
730IF FNthree(1,4,7) THEN =TRUE
740IF FNthree(2,5,8) THEN =TRUE
750IF FNthree(3,6,9) THEN =TRUE
760IF FNthree(1,5,9) THEN =TRUE
770IF FNthree(3,5,7) THEN =TRUE
780=FALSE
790DEFFNthree(s1,s2,s3)
800= (P$(s1)=C$ AND P$(s2)=C$ AND P$(s
3)=C$)
810
820DEFPROCTHINK
830move=0
840IFFNtwome(1,2,3) THEN move=3:ENDPRO
C
850IFFNtwome(2,3,1) THEN move=1:ENDPRO
C
860IFFNtwome(1,4,7) THEN move=7:ENDPRO
C
870IFFNtwome(4,7,1) THEN move=1:ENDPRO
C
880IFFNtwome(7,8,9) THEN move=9:ENDPRO
C
890IFFNtwome(8,9,7) THEN move=7:ENDPRO
C
900IFFNtwome(6,9,3) THEN move=3:ENDPRO
C
910IFFNtwome(3,6,9) THEN move=9:ENDPRO
C
920IFFNtwome(1,5,9) THEN move=9:ENDPRO
C
930IFFNtwome(5,9,1) THEN move=1:ENDPRO
C
940IFFNtwome(3,5,7) THEN move=7:ENDPRO
C
950IFFNtwome(7,5,3) THEN move=3:ENDPRO
C
960IFFNtwome(3,9,6) THEN move=6:ENDPRO
C
970IFFNtwome(8,5,2) THEN move=2:ENDPRO
C
980IFFNtwome(4,5,6) THEN move=6:ENDPRO
C
990IFFNtwome(6,5,4) THEN move=4:ENDPRO
C
1000IFFNtwome(3,7,5) THEN move=5:ENDPRO
C
1010IFFNtwome(1,9,5) THEN move=5:ENDPRO
C
1020IFFNtwome(2,8,5) THEN move=5:ENDPRO
C
1030IFFNtwome(4,6,5) THEN move=5:ENDPRO
C
1040IFFNtwome(1,3,2) THEN move=2:ENDPRO
C
1050IFFNtwome(2,5,8) THEN move=8:ENDPRO
C
1060IFFNtwome(7,9,8) THEN move=8:ENDPRO
C
1070IFFNtwome(1,7,4) THEN move=4:ENDPRO
C
1080IFP$(5)=B$ AND P$(1)=" " AND RND(10
)<7 THEN move=1:GOTO 1100
1090IFP$(5)=B$ AND P$(3)=" " AND RND(10
)<7 THEN move=3
1100IFP$(5)=" " AND RND(10)<9 THEN move
=5
1110IFFNtwoyou(1,2,3) THEN move=3
1120IFFNtwoyou(2,3,1) THEN move=1
1130IFFNtwoyou(1,4,7) THEN move=7
1140IFFNtwoyou(4,7,1) THEN move=1
1150IFFNtwoyou(7,8,9) THEN move=9
1160IFFNtwoyou(8,9,7) THEN move=7
1170IFFNtwoyou(6,9,3) THEN move=3
1180IFFNtwoyou(3,6,9) THEN move=9
1190IFFNtwoyou(1,5,9) THEN move=9
1200IFFNtwoyou(5,9,1) THEN move=1
1210IFFNtwoyou(3,5,7) THEN move=7
1220IFFNtwoyou(7,5,3) THEN move=3
1230IFFNtwoyou(3,9,6) THEN move=6
1240IFFNtwoyou(8,5,2) THEN move=2
1250IFFNtwoyou(4,5,6) THEN move=6
1260IFFNtwoyou(6,5,4) THEN move=4
1270IFFNtwoyou(3,7,5) THEN move=5
1280IFFNtwoyou(1,9,5) THEN move=5
1290IFFNtwoyou(2,8,5) THEN move=5
1300IFFNtwoyou(4,6,5) THEN move=5
1310IFFNtwoyou(1,3,2) THEN move=2
1320IFFNtwoyou(2,5,8) THEN move=8
1330IFFNtwoyou(7,9,8) THEN move=8
1340IFFNtwoyou(1,7,4) THEN move=4
1350IF move<>0 THEN ENDPROC
1360REPEAT:move=RND(9):UNTIL P$(move)="
":ENDPROC
1370DEFFNtwoyou(p1,p2,p3)
1380=(P$(p1)=B$ AND P$(p2)=B$ AND P$(p3
)=" ")
1390DEFFNtwome(p1,p2,p3)
1400=(P$(p1)=A$ AND P$(p2)=A$ AND P$(p3
)=" ")
1410
1420DEFPROCPLAYAGAIN
1430REPEAT:PRINTTAB(29,26);"ANOTHER?":Y
N=GET:UNTIL YN=89 OR YN=78
1440IF YN=78 playagain=FALSE:PRINTTAB(2
9,26);" BYE! ":ENDPROC
1450PRINTTAB(29,7);"OPPONENT":PRINTTAB(
29,12);"COMPUTER":playagain=TRUE:ENDPROC
1460DEFPROCSHOWMOVE(C)
1470COLOUR(128+(3*C)):COLOUR(3-(3*C))
1480IFmove>0 THEN PRINTTAB(H2,V2);move
1490COLOUR128:COLOUR3:ENDPROC
1500
1510DEFPROCDISPLAYCOUNTERS
1520PRINTTAB(32,9);yourcounter:PRINTTAB
(32,14);mycounter:ENDPROC
1530
1540DEFPROCERROR
1550REPEAT:PRINTTAB(29,26);" EXIT ? ":G
=GET:UNTIL G=78 OR G=89
1560IF G=78 THEN GOTO 110
1570PRINTTAB(29,26);" O.K. ":GOTO 140
:ENDPROC