Welcome Guest [Log In] [Register]
Add Reply
TicTacToo
Topic Started: Jan 10 2008, 08:13 AM (447 Views)
astropirate
Member Avatar
Not Lurking
[ * ]
This is the plain code for the Ti83/plus. Game:Tictactoo

Code:
 
\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\

You will Bow before me!

Posted ImagePosted Image
Offline Profile Quote Post Goto Top
 
techwizrd
Member Avatar
Magister ex Machina
[ *  *  * ]
I had this on my calculator along time ago.
My DeviantArt user page Please comment and add me to your favorites!
Posted Image
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Finished Projects · Next Topic »
Add Reply