              Ŀ           Ŀ                  Ŀ
 Ĵ  Ŀ   ĿĿĿ      ĿĴĿĿ      Ŀڿ ڿĿĿ
                                   ٳ    
   Ĵ    Ĵ      Ĵ     
                                                          

                        Ŀ       Ŀ
                     Ŀ ۳                   
                        ۳ ۳                  
                       Ŀ۳                   
                        ٲ                         
                     ٱ Ŀ ٱĿ                  
                                        
                                         


                                   T  I  C
                                  
                                   T  A  C
                                  
                                   T  O  E


Welcome to the Hugi Size Coding Compo number 21.

This time the task is to code the small game called "Tic-Tac-Toe". Not
only is the game small, but your program should be too. The winner of the
compo is the one who codes the smallest implementation of the following
rules. Have fun!


      

       Description  
   
         

The game is known in all parts of the world, but by various names. In
England it's "noughts and crosses". In Germany it's called "cheese-boxes".
Americans call it "tic-tac-toe".

The original name was "tit-tat-toe", which made sense. "Tit for tat" is a
retaliation, and "toe" supports the first two, for three in a row. "Tit"
was probably changed to "tic" with an eye toward political correctness.

The game was played in Egypt over 3500 years ago, and by now probably
everyone has caught on. (But just in case:) A field is divided into 3x3
parts. Two players take turns placing their sign into any of the nine
free parts. The goal is to get three of your signs in a row; either
horizontally, vertically or diagonally.


      

       The Program  
   
         

The computer program you are to write competes against a human player.
This means you've got to implement some kind of "artificial intelligence"
(AI). Specifically it means that your program must be smart enough that
it never loses a game. What kind of algorithm you implement is your
choice.

The player makes a move by pressing the key on the numeric keypad that
corresponds to one of the nine positions in the playfield.

                              Ŀ
                               7  8  9 
                              Ĵ
                               4  5  6 
                              Ĵ
                               1  2  3 
                              
                               0     
                              

The player always gets to go first, but the 0 key is used to skip a move.
Thus it can be used to let the computer play first.

The Esc key is used to terminate the program.

All of the other keys must be ignored, except the other numeric keys on
the top row. Num Lock must be on.

BIOS interrupt 16h function 0 must be used to read a character from the
keyboard. This is required so that your program can be verified with the
test suite.


      

       The Screen   
   
         

The playfield is drawn using the box character set like this: 

                                     
                               
                                     
                               
                                     

(For you poor Windoze users without an OEM font, it's a big version of
this: #.) The box characters are the extended ASCII characters B3h (),
C4h () and C5h ().

The signs are a nought and cross, which are displayed as an uppercase "O"
and "X". They are drawn in the centers of the nine positions of the play-
field. The player marks moves with the "X" and the computer uses the "O".

The 40x25 text screen (mode 1) is used. The playfield is centered on the
21st column and 13th row. The flashing cursor must be turned off
(typically using interrupt 10h function 1). When the program terminates,
the normal 80x25 text screen (mode 3) and the flashing cursor must be
restored. (Interrupt 10h function 0 is sufficient to do both.)

When a game is finished, a message must declare the winner. For example,
if the computer wins, "O wins!" is displayed. If nobody wins, "A draw!"
is displayed. All messages are centered below the playfield, starting
in the 18th column and 21st row.


      

       The Steps    
   
         

Here are the steps that must be done:

    Switch to 40x25 text screen (mode 1)
 0: Clear the screen
    Turn off the flashing cursor
    Draw the playfield (#)

 1: Wait for then read a keystroke using interrupt 16h, function 0
    If it's an Esc (1Bh) then go to 4
    If it's a 0 then skip to 2
    If it's not 1 thru 9 then go back to 1
    If the position is already occupied then go back to 1

    Draw an "X" in the specified position
    If there are three X's in a row then display "X wins!" and go to 3
    If there are no more moves available then display "A draw!" and go to 3

 2: Generate the computer's move
    Draw an "O" in the position it plays
    If there are three O's in a row then display "O wins!" and go to 3
    If there are no more moves available then display "A draw!" and go to 3
    Go to 1

 3: Wait for a keystroke
    If it's not an Esc then go to 0
 4: Restore 80x25 text screen (mode 3) and the flashing cursor
    Return to DOS

See GENERAL.TXT for additional rules and assumptions.


      

       Submitting   
   
         

Before submitting your entry make sure it passes the test suite by
running TTT_TEST ENTRY.COM (A blank screen for several minutes is
normal.)

Send your entries to this address:

                ------->>  fys@cybertrails.com  <<-------

You may submit updates to your entries any time until the deadline.


      

       Schedule     
   
         

2003-Feb-09: Compo 21 starts
2003-Mar-15 23:59:59 MST: Submission deadline (beware of the Ides of March)
2003-Mar-16: Sourcepack will be released, public judgment starts
2003-Mar-23: End of public judgment, final results will be released


      

       Creditz      
   
         

A big THANKS to Bonz for writing the test suite and making this compo
happen. Thanks also goes to Sniper for volunteering to be the host.
Thanks claw for writing these rules. Boreal gets credit for editing the
rules and for the assembly language example. The fancy fonts were stolen
from TAD. Adok, thank you for being our inspiration. Finally, thanks goes
to all you competetors who make these compos worthwhile.

Have fun!
