From: ij59@vaxb.acs.unt.edu
Subject: Tic-Tac-TI for TI-81
Organization: University of North Texas
Date: Sun, 4 Oct 1992 03:27:15 GMT

Well, here is my second program (actually the first game I wrote for the
TI).  It should be fairly self-explanatory.  PrgmE is optional.   This
is a complete listing of what I had in memory as of 9-25-91, so it
included E, which has nothing to do with Tic-Tac-TI, and it also uses
Prgmo as a subroutine instead of just having the Prgmo code as part
of the main program because I use Prgmo with many other programs
and thus only have to type it once.  (Hence the extension, .ALL instead
of .TIC, indicating that it is a subroutine used by many programs. .EXE
means that is an executable main program.)

The game uses the cross-hair entry method - just move it to where
you want your piece.  The computer only looks 1 move ahead, so there
is a chance to win.  (i.e. it blocks any two-in-a-row of yours and
will place the third in a row of two if it has one, but, beyond those
two conditions, it plays randomly.  This actually works very well for
Tic-Tac-Toe and prevents an algorithm based version that always plays
the same.)

The matrix dimension settings in TIC.EXE (i.e. 3->Arow, etc.) are actually
unecessary.  They are a carry-over from when the matrix A itself was used
to display the board instead of a graphical representation.  I don't remember 
why I defined the dimensions for matrices B & C; it was probably for
debugging purposes so it would only show me the parts of the matrices that
were relevant to the game.  At any rate, their initialization is optional,
but make sure that the matrix dimensions are at least that big before
you try to run it (or just leave the dimension settings in TIC.EXE.)

Please note: I've never tested this mem-dump, so there may be typos.
Have fun finding them! :)
---------------------------------------------------------------------------

o = Theta    -> = STO->

                                 TI-81 Memo-Dump
                                     9-25-91


DIRECTORY LISTING:

1:Prgm1 TIC.EXE    0:Prgm0 TST4.TIC    I:PrgmI             R:PrgmR
2:Prgm2 TST1.TIC   A:PrgmA SELC.TIC    J:PrgmJ             S:PrgmS
3:Prgm3 COM1.TIC   B:PrgmB DRAW.TIC    K:PrgmK             T:PrgmT
4:Prgm4 COM2.TIC   C:PrgmC PLYR.TIC    L:PrgmL             U:PrgmU
5:Prgm5 ROWS.TIC   D:PrgmD             M:PrgmM             V:PrgmV
6:Prgm6 COLS.TIC   E:PrgmE ENTER       N:PrgmN             W:PrgmW
7:Prgm7 DIAS.TIC   F:PrgmF             O:PrgmO             X:PrgmX
8:Prgm8 TST2.TIC   G:PrgmG             P:PrgmP             Y:PrgmY
9:Prgm9 TST3.TIC   H:PrgmH             Q:PrgmQ             Z:PrgmZ
                                                           o:Prgmo RNGE.ALL

---------------------------------------------------------------------------

PROGRAM LISTINGS:

Prgm1:TIC.EXE                           {Prgm1 continued}
:3->G                                   :Input M
:Disp "TIC-TAC-TI (TM)"                 :ClrHome
:Disp "BY SCOTT MILLER "                :If M=2
:Disp "(C) 1991"                        :Goto H
:Disp "ACE TECHNOLOGIES"                :Disp "WHO GOES FIRST?"
:Pause                                  :Disp "(1=ME  2=YOU)"
:Prgmo                                  :Input P
:3->Arow                                :ClrHome
:3->Acol                                :ClrDraw
:2->Brow                                :Line(36,56,36,10)
:4->Bcol                                :Line(54,56,54,10)
:2->Crow                                :Line(18,41,73,41)
:4->Ccol                                :Line(18,25,73,25)
:0->[A]                                 :If P=2
:ClrHome                                :Goto H
:Disp "1 OR 2 PLAYERS?"                 :Lbl C
-----------------------------------     :1->G
Prgm2:TST1.TIC                          :Prgm2
:[A](1,1)[A](1,2)[A](1,3)->[B](1,1)     :If A=0
:[A](2,1)[A](2,2)[A](2,3)->[B](1,2)     :Prgm3
:[A](3,1)[A](3,2)[A](3,3)->[B](1,3)     :If A<>0
:[A](1,1)[A](2,1)[A](3,1)->[B](1,4)     :Prgm4
:[A](1,2)[A](2,2)[A](3,2)->[B](2,1)     :Lbl H
:[A](1,3)[A](2,3)[A](3,3)->[B](2,2)     :Prgm2
:[A](1,1)[A](2,2)[A](3,3)->[B](2,3)     :PrgmA
:[A](1,3)[A](2,2)[A](3,1)->[B](2,4)     :PrgmB
:0->W                                   :If M<>2
:1->Y                                   :Goto C
:0->A                                   :Prgm2
:Lbl 1                                  :PrgmA
:1->X                                   :PrgmB
:Lbl 2                                  :Goto H
:If [B](Y,X)=1                          (:End)
:1->W                                   ------------------------------------
:If [B](Y,X)=27                         {Prgm2 continued}
:2->W                                   :Lbl C
:IS>(X,4)                               :If M=2
:Goto 2                                 :Goto X
:IS>(Y,2)                               :Disp "HAH! YOU LOSE!"
:Goto 1                                 :Disp "I WON!"
:If W=1                                 :Disp "I WON!"
:Goto C                                 :Disp "I WON!"
:If W=2                                 :Disp "HAH!"
:Goto H                                 :Stop
:1->Q                                   :Lbl X
:1->Z                                   :Disp ""
:Lbl U                                  :Disp "O WINS!"
:1->R                                   :Stop
:Lbl N                                  :Lbl H
:Z*[A](R,Q)->Z                          :If M=2
:IS>(R,3)                               :Goto O
:Goto N                                 :Disp ""
:IS>(Q,3)                               :Disp "YOU WON."
:Goto U                                 :Stop
:If Z<>0                                :Lbl O
:Goto E                                 :Disp ""
:Prgm8                                  :Disp "X WINS!"
:End  {continued, see 2nd column}       :Stop
-----------------------------------     :Lbl E
Prgm3:COM1.TIC                          :Disp ""
:Lbl 1                                  :Disp "TIE GAME."
:Int (Rand*3)+1->X                      :Stop
:Int (Rand*3)+1->Y                      (:End)
:If [A](X,Y)<>0                         -----------------------------------
:Goto 1                                 Prgm4:COM2.TIC
:PrgmB                                  :If A=2
(:End)                                  :Goto 1
-----------------------------------     :If B<>4
Prgm5:ROWS.TIC                          :Prgm5
:1->G                                   :If B=4
:1->Y                                   :Prgm6
:B->X                                   :End
:Lbl 1                                  :Lbl 1
:f [A](B,Y)=0                           :If B<3
:PrgmB                                  :Prgm6
:IS>(Y,3)                               :If B>2
:Goto 1                                 :Prgm7
(:End)                                  (:End)
-----------------------------------     -----------------------------------
Prgm6:COLS.TIC                          Prgm7:DIAS.TIC
:1->X                                   :If B=4
:1->Y                                   :Goto 2
:If A=2                                 :1->X
:Goto 2                                 :Lbl 1
:Lbl 1                                  :X->Y
:If [A](X,1)=0                          :If [A](X,Y)=0
:PrgmB                                  :PrgmB
:IS>(X,3)                               :IS(X,3)
:Goto 1                                 :Goto 1
:End                                    :End
:Lbl 2                                  :Lbl 2
:1->X                                   :1->X
:Lbl 3                                  :Lbl 3
:B+1->Y                                 :4-X->Y
:If [A](X,B+1)=0                        :If [A](X,Y)=0
:PrgmB                                  :PrgmB
:IS>(X,3)                               :IS(X,3)
:Goto 3                                 :Goto 3
(:End)                                  (:End)
-----------------------------------     -----------------------------------
Prgm8:TST2.TIC                          Prgm9:TST3.TIC
:[A](1,1)+[A](1,2)+[A](1,3)->[C](1,1)   :If A<>0
:[A](2,1)+[A](2,2)+[A](2,3)->[C](1,1)   :End
:[A](3,1)+[A](3,2)+[A](3,3)->[C](1,1)   :Y->A
:[A](1,1)+[A](2,1)+[A](3,1)->[C](1,1)   :X->B
:[A](1,2)+[A](2,2)+[A](3,2)->[C](1,1)   (:End)
:[A](1,3)+[A](2,3)+[A](3,3)->[C](1,1)   -----------------------------------
:[A](1,1)+[A](2,2)+[A](3,3)->[C](1,1)   Prgm0:TST4.TIC
:[A](1,3)+[A](2,2)+[A](3,1)->[C](1,1)   :Y->A
:0->A                                   :X->B
:1->Y                                   -----------------------------------
:Lbl 1                                  PrgmA:SELC.TIC
:1->X                                   :If M=2
:Lbl 2                                  :PrgmC
:If [C](Y,X)=2                          :If M=2
:Prgm0                                  :Goto 1
:If [C}(Y,X)=6                          :3->G
:Prgm9                                  :Lbl 1
:IS>(X,4)                               :Input
:Goto 2                                 :2->J
:IS(Y,2)                                :If X<36
:Goto 1                                 :1->J
(:End)                                  :If X>54
-----------------------------------     :3->J
PrgmB:DRAW.TIC                          :2->I
:G->[A](X,Y)                            :If Y>41
:54->J                                  :1->I
:If X=2                                 :If Y<25
:38->J                                  :3->I
:If X=3                                 :If [A](I,J)<>0
:22->J                                  :Goto 1
:20->I                                  :I->X
:If Y=2                                 :J->Y
:38->I                                  (:End)
:If Y=3                                 -----------------------------------
:57->I                                  PrgmC:PLYR.TIC
:If G=1                                 :If G=1
:Goto O                                 :Goto 2
:Line(I+2,J,I+12,J-10)                  :1->G
:Line(I+12,J,I+2,J-10)                  :End
:End                                    :Lbl 2
:Lbl O                                  :3->G
:Line(I+2,J-3,I+2,J-7)                  -----------------------------------
:Line(I+3,J-1,I+3,J-2)                  PrgmD:
:Line(I+3,J-8,I+3,J-9)                  :
:Line(I+6,J+1,I+8,J+1)                  (:End)
:Line(I+6,J-11,I+8,J-11)                -----------------------------------
:Line(I+4,J,I+5,J)                      PrgmE:ENTER
:Line(I+9,J,I+10,J)                     :ClrHome
:Line(I+11,J-1,I+11,J-2)                :Disp "PRESS ENTER."
:Line(I+12,J-3,I+12,J-7)                :Pause
:Line(I+11,J-8,I+11,J-9)                :Disp ""
:Line(I+9,J-10,I+10,J-10)               :Disp "THANKS!"
:Line(I+4,J-10,I+5,J-10)                (:End)
(:End)                                  -----------------------------------
-----------------------------------     Prgm(F-Z):
Prgmo:RNGE.ALL                          :
:All-Off                                (:End)
:1->Xmin                                -----------------------------------
:96->Xmax
:0->Xscl
:1->Ymin
:64->Ymax
:0->Yscl
----------------------------------


 ________    _______              _         ________     ____
|______  |  |_____  |            | |       |________|   |____|
      / /         | |  _  _   _  |  \       ________    ______   _______
     /  \         | | |_||_| / / |   \     |________|  |____  | |_______|
    / /\ \   _____| |   ____/ /  | |\ \     ________       / /
   /_/  \_\ |_______|  |_____/   |_| \/    |________|     /_/
 
        |  Nippon no anime wa ichi-ban desu!  Otaku rule!    |
        |      Hey, man, I _like_ Robotech.  So sue me.      |
        | Sukotto Miraa/Scott Miller (ij59@vaxb.acs.unt.edu) |

President of Ace Technologies, the (among other things) TI-81 Freeware 
Development Company.  :)