This is a gzipped tar file which includes the source code and a makefile for compiling the interface. You can compile it with either the graphical user interface or without it. The way to switch between the two versions is through a simple modification of the makefile. Look in the makefile to see how this is done. If you compile without the graphical user interface then it will print out the moves and board in a text based format.
The code is not cross-platform compatible. If you want to run/compile it on a dos/windows (or mac) computer then you're on your own as to the modifications you'll need to make.
Your first assignment is to write a checkers program that uses a simple depth limited search to search for good moves. The depth of the search will be passed to your program via a command line parameter. Currently myprog.c looks for 3 command line parameters:
writefd = atoi(argv[1]); /* File descriptor for writing to pipe */ readfd = atoi(argv[2]); /* File descriptor for reading from pipe */ SecPerMove = (float) atof(argv[3]); /* Time allotted for each move */
Set up a 4th one to be the maximum search depth. Something like (I've actually already added this to myprog.c):
MaxDepth = atoi(argv[4]); /* Maximum search depth */
Don't worry too much about the amount of time per move for this part of the checkers program. However, if you have an extremely inefficient search algorithm you may be penalized.
Use the following simple heuristic in order to evaluate a particular move sequence:
#your_checkers - #opponents_checkers
In this formula a king counts for 2 checkers (since it takes 2 checkers to make a king) and so the formula considers a king to be twice as valuable as a non-king. Make sure that you USE THE MINI-MAX method for determining which move to make. With this method you assume that your opponent will always make the best possible move for himself.
Your assignment is to write your own checkers program. The only restrictions are:
You must return a legal move before the time expires You cannot deliberately sabotage your opponents efforts. This means among other things that you must free all possible memory after your move and you must not use cpu cycles durring your opponent's moves
Your program should look for the following 3 command line parameters:
writefd = atoi(argv[1]); /* File descriptor for writing to pipe */ readfd = atoi(argv[2]); /* File descriptor for reading from pipe */ SecPerMove = (float) atof(argv[3]); /* Time allotted for each move */
With this part of the assignment you need to turn in a few pages explaining what you did, the strategies and heuristics you used, and etc. Part of your grade will be based on how well your program performs against others.
To pass of your assignment(s), upload your executable checkers program via anonymous ftp to axon.cs.byu.edu (or hut.cs.byu.edu) in the directory
pub/470/upload/checkers1/bin
or if you are uploading the 2nd checkers program,
pub/470/upload/checkers2/bin
Use the following convention in naming your program: Last name followed by first initial (you should also follow this with a number to distinguish it from any pervious uploads you may have done). For example, if your name is Tim Andersen you would call your program andersent.
Upload a tar'ed version of your executable program and source code to the directory pub/470/upload/checkers/src.
tar -cvf tarfile sourcefiles
gzip tarfile
Use the same naming convention but with a .gz extenstion (andersent.gz).
Finally, you should hand in a hard copy of your writeup in class.
To help you in the evaluation of how well you program is doing, we've put a few programs from past classes into the pub/470/download/checkers directory to test your program against.
It is also highly recommended that AFTER you upload your program you immediately download it back to the machine you're on and make sure it works correctly. If it didn't get uploaded correctly or for whatever reason doesn't work YOU WILL BE PENALIZED.
After you have done this, email me at tim@axon.cs.byu.edu with the names of the files and any other pertinent information. For the second checkers program you will also need to turn in a few pages explaining what you did and how clever you were.
The items in pub/470/upload/checkers/bin will be visible, so that you can download other peoples executable checkers programs and test them against your own if you wish. Since it is visible, DO NOT put your source code into this directory. I don't want people cheating by using other peoples source code.
Here is a copy of the latest checkers interface (save this link to a file). The latest version allows you to pass a maximum search depth parameter to your checkers program. To get it to do this, run the program with the parameter
-MaxDepth x
where x is some integer. For example, to run with a maximum search depth of 5 you would type
checkers -MaxDepth 5
To play as a human enter "human" as one of the players when starting a new game.
We have provided C source code (myprog.c and myprog.h) for an example program that will show you how the communication between programs is done (it is really quite simple). This source code implements the following for you:
A representation of the checker board A function that finds all of the legal moves given the state of the checker board A function that takes a move and changes the state of the board to reflect the move Communication with the checker board program (to send and receive moves)
Feel free to use this program as a template for your checkers program. Currently this program simply selects a random move from the set of all possible legal moves given the current board position. You will need to modify this to a more intelligent form of search.
Here's the compiled version.
Here's how to interface your program with the checkers program. It can be done in a few simple steps:
Compile your program into a standalone executable Start the checkers program Choose 'New Game' from the file menu Type the name (and path if necessary) of your executable program for player 1 or player 2
Below is an example of how to set up a game where you (a human) play as red and your program 'myprogram' located in ~/bin plays as white.

Your search routine will be required to finish in a certain amount of time (something like 10 seconds for each move). The current version of myprog.c does not have any timing code inserted into it's search routine. The timing functions (such as LowOnTime) that are included are not guaranteed to work correctly, so I would advise you to code up your own timing routines.
The data structures that are defined in myprog.c for storing potential moves are sufficient for the simple search that it is doing, but may not be sufficient (or efficient) for whatever search routine you decide to use and may need to be modified. Feel free to change whatever you want.
The data structure in myprog.c which returns the list of possible moves has 48 places to store moves. This number is highly likely, but NOT GUARANTEED, to be sufficient. Intuitively, it would seem impossible to have more than 48 legal moves from a given board position. But we don't have a proof so it may be possible to generate a board position that would allow one player more than 48 different legal moves. It's your call on how to handle this.
The moves that you will be sending and receiving will be of the following form: start-a1-a2-...-end
start is the number of the starting square (where the piece begins its move)
a1..an are the numbers of the intermediate squares (used only for jumps)
end is the number of the final square (where the piece will end up)
An example opening move for red would be: 9-13
An example jump would be: 23-16-7
