3-D Xs and Os

3-D X's and O's title lettering
3-D X's and O's title lettering
Cube board with Xs and Os
Cube board with Xs and Os

P.R. SCOTT has sent the kind of program Mr. Spock plays on long, winter evenings. 3D Tic Tac Toe displays a cube and 27 possible positions for the Xs and Os. Unlike the 2D version, the game must be continued until all the positions are filled, the object being not to obtain the first completed row but as many as possible.

The player who starts has an advantage, as finally he occupies one space more than his opponent and so, to level matters, the first player is prevented from occupying the center square on his first attempt.

The program checks for that and other illegal moves, as well as setting-up the board, indicating whose turn is next, and giving the correct score throughout. Moves are entered by keying-in a letter, then a number, then ENTER. “A” indicates the front face of the cube, “B” the center and “C” the rear. Entering “R” will restart the game (T/S1000,ZX81, 16K).

   5 DIM A(27)
10 DIM C(18)
15 DIM R(18)
20 DIM X(27)
25 DIM Y(27)
30 LET X$="020814020814020814061218061218061218101622101622101622"
35 LET Y$="060606121212181818040404101010161616020202080808141414"
40 FOR Z=1 TO 27
45 LET X(Z)=VAL X$(2*Z-1 TO 2*Z)
50 LET Y(Z)=VAL Y$(2*Z-1 TO 2*Z)
55 NEXT Z
60 LET C$="020405050505060810111111111213131313"
65 LET R$="010301020304030109010809100903060912"
70 FOR Z=1 TO 18
75 LFT C(Z)=VAL C$(2*Z-1 TO 2*Z)
80 LET R(Z)=VAL R$(2*Z-1 TO 2*Z)
90 NEXT Z
100 FOR Z=1 TO 27
105 LET A(Z)=0
110 NEXT Z
115 LET S=1
120 LET N=1
170 CLS
175 GOSUB 1000
180 IF S=1 THEN PRINT AT 2,0;"""X"" TO GO"
185 IF S=-1 THEN PRINT AT 2,0;"""O"" TO GO"
190 PRINT AT 20,14;" "
200 INPUT Z$
205 IF N=28 THEN GOTO 100
210 IF Z$(1)="R" THEN GOTO 100
215 IF Z$(1)="A" THEN LET Z=0
220 IF Z$(1)="B" THEN LET Z=9
225 IF Z$(1)="C" THEN LET Z=18
235 LET Z=Z+VAL Z$(2)
240 IF A(Z)<>0 THEN GOTO 390
245 IF N=1 AND Z=14 THEN GOTO 390
250 LET A(Z)=S
255 LET N=N+1
260 IF S=1 THEN PRINT AT Y(Z),X(Z);"(inverse X)"
265 IF S=-1 THEN PRINT AT Y(Z),X(Z);"(inverse O)"
270 GOSUB 500
275 LET S=-S
280 GOTO 180
390 PRINT AT 20,14;"ILLEGAL, TRY AGAIN"
395 GOTO 200
500 FAST
505 LET SX=0
510 LET SO=0
515 FOR Z=1 TO 13
520 LET W=A(14-Z)+A(14)+A(14+Z)
525 IF ABS W=3 THEN GOSUB 800
530 NEXT Z
535 FOR Z=1 TO 18
540 LET W=A(C(Z)-R(Z))+A(C(Z))+A(C(Z)+R(Z))
545 IF ABS W=3 THEN GOSUB 800
550 LET V=28-C(Z)
555 LET W=A(V-R(Z))+A(V)+A(V+R(Z))
560 IF ABS W=3 THEN GOSUB 800
565 NEXT Z
570 PRINT AT 20,0;"(inverse X)=";SX;",(inverse O)=";SO
575 SLOW
580 RETURN
800 IF W=3 THEN LET SX=SX+1
803 IF W=-3 THEN LET SO=SO+1
810 RETURN
1000 PRINT AT 0,6;"3D NOUGHTS AND CROSSES"
Listing lines 1004-1036, board-drawing PRINT lines with block graphics
Listing lines 1004-1036, board-drawing PRINT lines with block graphics
1090 RETURN

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.