Upthrust Game Manager
---------------------
10/17/98
kenrick@cs.pdx.edu

Here is source code for an Upthrust game manager.  The source directory
contains two programs.  The first one is "gamemanager" and acts as a 
server that coordinates play among people or AI programs.  The
second program is called "dumbclient" and is an example of a dumb 
AI client that works with the manager.  It is intended only as 
an example of how to interface with the manager, and selects 
first valid move it can find.  Needless to say, your program 
should be able to beat dumbclient easily.

Note that you are not required to implement this interface.
If you wish, we can always run tournaments manually by entering moves
to each program to have computer programs play one another. However,
if you can implement this interface, AI play will be faster and
automatic.

You are free to use any of the source code here as a base for 
your own AI program.  If so, make sure that you work from the
dumbclient program, not the manager program.

If you find any bugs, have questions, or come up with enhancements 
to this package, please let me know!

Building the package
---------------------

Issue the command "make" and the programs "gamemanager" and
"dumbclient" should be built.  This has been tested on
solaris, sunos, and linux.

Game Manager Usage
--------------------

The gamemanager program takes three arguments.  The first
argument is the name of a program that will be player 1.  This
program will move first.  The second argument is the name of a program
that will be player 2.   If one of these arguments is "-" then that
player will be a human player rather than a program.

The third argument is a string that indicates the colors assigned
to player 1 and 2.  This string should be lowercase "r", "g",
"b", or "y".  The first two characters indicate the colors for
player 1, while the second two characters indicate the colors
for player 2.

For example, if two people wanted to play against each other, 
where player 1 is red and green while player 2 is blue and yellow,
they run it as:

        gamemanager - - rgby

If you want the "dumbclient" player to play itself where the
first player is red and yellow, then run it as:

	gamemanager dumbclient dumbclient rygb

If any client program (or the human) issues a move that is not
valid, then that player immediately loses the game.

Dumb Client Usage
--------------------

The other program in this package is called "dumbclient".  It is just a
skeleton implementation of a program that plays Upthrust.  It plays by
selecting the first valid move it can find, so it won't play very
well :)  It is included simply to show you how the AI program will 
interface with the game manager.  

The client is expecting one argument, a string that indicates
the colors and whether or not the program is moving first.  This
string will be available in argv[1].  The first four characters
of the string are as above, where the first two characters
indicate which colors the program is given.  The last two characters
indicate which colors the opponent is given.  These are
followed by a space and then a "1" if the program moves first,
otherwise this character will be a "0".

For example, invoking dumbclient with "yrgb 1" tells this client
that he is assigned colors yellow and red, the opponent is green
and blue, and that the client should move first.

See the client_main.c program for examples of how to parse
the input.


Move Format
--------------------

Send moves in the "X Y" format described previously.  In this format,
the X/Y coordinates of the piece to move is specified.  0 0 is the
lower left corner of the board, while 3 10 is the upper right corner.

Use the move "-1 -1" if no move is available.
Make sure that your program watches for this input and doesn't try
to actually update the board with a -1 -1 move.


Communications
--------------------

The game manager works by connecting the stdin and stdout of each
client program to a file descriptor within the game manager.
This means that stdin and stdout from the client program will
be redirected to the manager.

To fully implement a client AI, your program should parse the
color assignments from the argv string, and ONLY print
moves to stdout.  Moves from the opponent should be read from
stdin.  This means that your client cannot print a board or
any other information, or this will muck up the game manager.

You may want to implement a separate version that prints its own
board, for debugging purposes.  

See the functions in client_io.c and client_main.c for examples 
of how to send and get moves.  

