HiQUE Game Manager
---------------------
3/27/02
 Added current score to manager and nice -20

3/3/02
kenrick@uaa.alaska.edu

Here is source code for a HiQUE 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.  

Finally, there is a binary for a third program called
"smartclient" and it implements a 6 move lookahead player that
you can use to test your own program against.  The binary is
compiled for linux using one of the cslinux machines.

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!

-- kenrick@uaa.alaska.edu


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 be BLACK and move first.  The second argument is the name of a
program that will be player 2.   This will be the WHITE player and
will move second.

If one of these arguments is "-" then that
player will be a human player rather than a program.

For example, if two people wanted to play against each other, 
where player 1 is black and player 2 is white
they run it as:

        gamemanager - - 

If you want the "dumbclient" player to play "smartclient" where the
white player is dumbclient and the black player is smartclient then
invoke the program as:

	gamemanager smartclient dumbclient

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 HiQUE.  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
whether or not this player is white or black.  The string is
available in argv[1].  This string will be "white" if the
program is to be the white player, or "black" if this program
is to be the black player and should therefore move first.

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


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

Send moves in the "X-OLD Y-OLD X-NEW Y-NEW" format described previously.  



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
initial color of who moves first 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.  


Writing a game-manager compliant program
----------------------------------------

To make your HiQUE program complaint with the game manager, you have
two choices.  

1) Modify your program to work with the manager.  This means stripping
out any output (e.g. printing the board) and adding the proper routines
to read and write input from the manager.  You'll probably want to
import client_io.c into your program to send and receive moves. Your
program should also parse the input arguments to determine if it is 
the white or black player.

2) Use the dumbclient code as a base, and replace the AI routine with
your own.   This would mean changing client_main.c, client_ai.c, and
any other support files that your program uses.


