# TIC (C64) by Kevin Prosser

A downloadable game

TIC

This is a Tic Tac Toe game for the Commodore 64.

A 3x3 matrix will appear representing the TIC TAC TOE game. The user plays X and the Computer plays O. When Prompted for a “MOVE?”, type the number of the grid square where you would like to place your X. The screen will redraw with your X in place while the computer decides its next move. The screen will then redraw again with the computers move and the process continues until there is a winner or a tie. The game is suitable for kids as the computer will generally make good moves but is not unbeatable.

Line by line description:

0 DIMB(38):DIMT(38):DIMA(38):FORI=1TO23:READB(I),T(I),A(I):NEXT:GOSUB6:DATA2,0

Dimension arrays for bitwise mask, test, and action arrays and reads that data,

GOSUB is for the display routine.

1 PRINT"SMOVE?":GETG$:M=VAL(G$):M=-(M<9)*M:l=2^M:if(G$="")or((X+OANDl)>0)THENGOTO1

Get X move and test to see if it is a free space. X and O are 9 bit integers that represent all the spaces held by the X and O marks. They are automatically initialized to zero at program execution.

2 X=X+2^M:GOSUB6:IFX+O>510THENPRINT"TIE":END:DATA1,8,0,3,32,0,5,128,0,7,64,0,6,4,0,2

Update X value. X is a 9bit integer of spaces the Xs are in. If all spaces full without winner then tie.

3 FORI=1to23:IF(XANDB(I))=T(I)AND(OAND2^A(I))=0THENM=A(I):DATA1,0,0,256,0,8,16,0

Evaluate defensive moves from lowest priority to highest, save the best move as M.

4 NEXT:FORI=15TO23:IF(OANDB(I))=T(I)AND(XAND2^A(I))=0THENM=A(I):DATA4,457,129,6

Look for opportunities for O to win and take them if available.

5 NEXT:)O=O+2^M:GOSUB6:GOTO1:DATA457,257,6,457,136,6,457,264,6,295,258,2,7,3,2

Call the routine to display new board and check for a winner routine.

6 PRINT"SQQ":FORI=0TO2:FORJ=0TO2:K=3*I+J:L=2^K:S=88+((OANDL)=0AND(XANDL)=0)*(40-K)

Display new board, S is ascii code of item in the current square, X,O, or number of square

7 S=S+9*((OANDL)>0):R=18-128*(S<70):PRINTCHR$(R)+CHR$(S);:NEXT:PRINT:NEXT

R is code for reverse video if an X or O is in the square

8 FORI=15TO22:Z=Z+((XANDB(i))=B(I)OR(OANDB(I))=B(I)):NEXT:IFZ<0THENPRINT"WIN!":END

Check for a winner which are moves 15-22. Z is zero by default unless any row/col/diagonal has all 1s

9 RETURN:DATA56,24,5,448,320,7,73,9,6,146,18,7,292,260,5,273,272,0,84,80,2,7,5,1

More data

Status | Released |

Author | BASIC 10Liner |

Genre | Strategy |

Tags | 8-Bit, basic, basic10liner, Commodore 64 |

## Download

## Install instructions

This program works nicely on the C64 VICE Emulator. To play, load the game from disk:

LOAD”TIC”,8

When loaded, type RUN and return to start the game.

## Comments

Log in with itch.io to leave a comment.

very good