1 DATA 2,3,4,9,1,5,8,7,6 
2 DATA 2,3,4,9,1,5,8,7,6,2,9,8,3,1,7 
3 DATA 4,5,6,2,1,6,4,1,8 
4 DATA 0,1,-1,1,-1,1,-1,1,-1 
5 DIM A(9) 
6 DIM B(9) 
7 DIM C(24)
8 DIM D(24)
9 DIM F(9) 
10 FOR I=1 TO 9 
11 READ A(I)
12 NEXT I 
13 FOR I=1 TO 24
14 READ C(I)
15 NEXT I 
16 FOR I=1 TO 9 
17 READ F(I)
18 NEXT I 
19 PRINT "TIC-TAC-TOE"
20 PRINT
21 PRINT "THE MOVE POSITIONS ARE:"
22 PRINT
23 PRINT "1 2 3"
24 PRINT "4 5 6"
25 PRINT "7 8 9"
26 GOSUB 133
27 GOSUB 133
32 LET E=0
33 LET G=2
34 LET K=0
35 FOR I=1 TO 9 
36 LET B(I)=0 
37 NEXT I 
38 FOR I=1 TO 24
39 LET D(I)=0 
40 NEXT I 
41 PRINT
42 PRINT
43 PRINT "--BEGIN GAME--" 
44 PRINT "YOU WILL BE 'X', I WILL BE 'O'" 
47 PRINT "TYPE 0 IF YOU WANT ME TO GO FIRST"; 
48 INPUT I
49 IF I=0 THEN 65 
50 LET L=-1 
51 PRINT "YOUR MOVE"; 
52 INPUT I
53 PRINT
54 PRINT
55 LET H=INT(ABS(I))
56 IF H<>I THEN 50
57 IF H < 1 THEN 50 
58 IF H>9 THEN 50 
59 LET H=A(H) 
60 IF B(H) <> 0 THEN 50 
61 IF K=1 THEN 64 
62 LET G=F(H) 
63 LET K=1
64 GOSUB 111
65 LET L=1
66 FOR I=1 TO 22 STEP 3 
67 IF D(I) + D(I+1) + D(I+2) = -3 THEN 92 
68 NEXT I 
69 FOR I=1 TO 22 STEP 3 
70 IF D(I) + D(I+1) + D(I+2) = 2 THEN 90
71 NEXT I 
72 FOR I=1 TO 22 STEP 3 
73 IF D(I) + D(I+1) + D(I+2) = -2 THEN 106
74 NEXT I 
75 IF E=1 THEN 77 
76 IF G = -1 THEN 78
77 IF B(1)=0 THEN 100 
78 IF G <> 0 THEN 82
79 FOR I=2 TO 8 STEP 2
80 IF B(I)=0 THEN 101 
81 NEXT I 
82 IF H=8 THEN 86 
83 FOR I=H+1 TO 8 
84 IF B(I)=0 THEN 101 
85 NEXT I 
86 FOR I=2 TO 9 
87 IF B(I)=0 THEN 101 
88 NEXT I 
89 GO TO 98 
90 PRINT "I WIN"
91 GOTO 900 
92 PRINT "YOU ARE NOT ALLOWED TO WIN" 
93 FOR I=1 TO 9 
94 LET B(I)=1 
95 NEXT I 
96 GOSUB 117
97 GOTO 900 
98 PRINT "DRAW" 
99 GOTO 900 
100 LET I=1
101 LET H=I
102 GOSUB 111
103 LET E=1
104 GOSUB 117
105 GO TO 50 
106 FOR J=I TO I+2 
107 IF D(J)=0 THEN 109 
108 NEXT J 
109 LET I=C(J) 
110 GO TO 101
111 LET B(H)=L 
112 FOR M=1 TO 24
113 IF C(M) <> H THEN 115
114 LET D(M)=L 
115 NEXT M 
116 RETURN 
117 FOR N=1 TO 9 
118 IF B(N)=0 THEN 200 
119 NEXT N 
120 IF N<100 THEN 98 
121 FOR N=1 TO 9 STEP 3
122 FOR O= 0 TO 2
123 IF B(A(O+N))=0 THEN 127
124 IF B(A(O+N))=1 THEN 129
125 PRINT "X ";
126 GO TO 130
127 PRINT "- ";
128 GO TO 130
129 PRINT "O ";
130 NEXT O 
131 PRINT
132 NEXT N 
133 PRINT
136 RETURN 
137 STOP 
200 LET N=1000 
210 GOTO 119 
900 GOTO 910
910 PRINT "TRY AGAIN (IF SO TYPE 0)";
920 INPUT I
930 IF I<>0 THEN 999 
940 GOTO 27
999 END
