tictacto TI-82 Source Code - Skip Header

tictacto TI-82 Source Code

This is intended to be the human readable version of the source code for Tic-Tac-Toe. This version is intended to work only on the TI-82 Texas Instruments graphic calculator. Also available: Documentation about "Tic-Tac-Toe" and versions of the program for other calculators and in other formats.

Any line that begins with a backslash is a comment and should not be entered into the calculator. (Comments have been colored green) For an authoritative copy of this program's source code that can be imported to the calculator via a computer, consult the text version of Tic-Tac-Toe source code for the TI-82, along with the character reference. The special character reference also gives an overview of all non-ASCII characters for the calculator, and shows the menus in which they can be found.

\START82\
\NAME=TICTACTO
\FILE=tictacto.82P
\COMMENT=Set up the graph to look nice for display
:FnOff 
:ZStandard
:ZInteger
:CoordOff
:AxesOff
\COMMENT=Draw the board
:Vertical -28
:Vertical -9
:Line(-47,12,9,12
:Line(-47,-7,9,-7
:Text(57,12,"TIC TAC TOE"
:Text(6,8,7
:Text(6,27,8
:Text(6,46,9
:Text(25,8,4
:Text(25,27,5
:Text(25,46,6
:Text(44,8,1
:Text(44,27,2
:Text(44,46,3
\COMMENT=A is who's turn is next, -1 is X, 1 is O
-1→A
\COMMENT=Initialize the variable for who owns each square
\COMMENT=Notice that the variable for each square
\COMMENT=corresponds with the place on the number keypad
:0→O
:0→P
:0→Q
:0→T
:0→U
:0→V
:0→S
:0→Z
:0→Θ
\COMMENT=Start a turn
:Lbl 1
:If A=1
:Text(28,75,"O"
:If A=-1
:Text(28,75,"X"
\COMMENT=Check for user input
\COMMENT=Then initialize variables accordingly
\COMMENT=(C,D) will be the coordinate to write
\COMMENT=text once a square has been picked
:Lbl 2
:getKey→B
:If B=72
:Then
:If O≠0
:Goto 2
:6→C
:8→D
:A→O
:Goto 3
:End
:If B=73
:Then
:If P≠0
:Goto 2
:6→C
:27→D
:A→P
:Goto 3
:End
:If B=74
:Then
:If Q≠0
:Goto 2
:6→C
:46→D
:A→Q
:Goto 3
:End
:If B=82
:Then
:If T≠0
:Goto 2
:25→C
:8→D
:A→T
:Goto 3
:End
:If B=83
:Then
:If U≠0
:Goto 2
:25→C
:27→D
:A→U
:Goto 3
:End
:If B=84
:Then
:If V≠0
:Goto 2
:25→C
:46→D
:A→V
:Goto 3
:End
:If B=92
:Then
:If S≠0
:Goto 2
:44→C
:8→D
:A→S
:Goto 3
:End
:If B=93
:Then
:If Z≠0
:Goto 2
:44→C
:27→D
:A→Z
:Goto 3
:End
:If B=94
:Then
:If Θ≠0
:Goto 2
:44→C
:46→D
:A→Θ
:Goto 3
:End
:Goto 2
\COMMENT=Write the correct symbol
\COMMENT=for the person who just made a move
:Lbl 3
:If A=-1
:Text(C,D,"X"
:If A=1
:Text(C,D,"O"
\COMMENT=Check to see if anybody has won
:If abs (S+T+O)=3
:Then
:Line(-38,22,-38,-16
:Goto 4
:End
:If abs (Z+U+P)=3
:Then
:Line(-19,22,-19,-16
:Goto 4
:End
:If abs (Θ+V+Q)=3
:Then
:Line(0,22,0,-16
:Goto 4
:End
:If abs (O+U+Θ)=3
:Then
:Line(-38,22,0,-16
:Goto 4
:End
:If abs (S+U+Q)=3
:Then
:Line(-38,-16,0,22
:Goto 4
:End
:If abs (O+P+Q)=3
:Then
:Line(-38,22,0,22
:Goto 4
:End
:If abs (T+U+V)=3
:Then
:Line(-38,3,0,3
:Goto 4
:End
:If abs (S+Z+Θ)=3
:Then
:Line(-38,-16,0,-16
:Text(34,69,"WINS"
:Goto 4
:End
\COMMENT=Check to see if all the squares are full
:If SZΘTUVOPQ≠0
:Then
:Text(28,69,"CATS"
:Text(34,68,"GAME"
:Goto 5
:End
\COMMENT=Make it the next players turn
\COMMENT=and go to the the start of the turn
:-A→A
:Goto 1
:Lbl 4
:Text(34,69,"WINS"
:Lbl 5
:Text(16,68,"GAME"
:Text(22,69,"OVER"
:Pause 
\COMMENT=Set the graph back to something
\COMMENT=More reasonable
:CoordOn
:AxesOn
:ZStandard
:Disp 
\COMMENT=Copyright Stephen Ostermiller 1996-2001
\STOP82\