This Assignment involves writing a program to play three dimensional noughts and crosses on a 4x4x4 board.
The board is a 4x4x4 array and the object of the game is to place four balls in a line. Lines may be horizontal, vertical or diagonal (including diagonal between opposing corners). Shown here is a winning position for the red (grey!) balls. There are 76 possible winning lines.
Your program needs to read a complete board position from a data file called "board" (must be lower case) in the current directory. Your program can then change the board position by making a move, and write the new position into the same file over the original data.
The "board" file consists of 64 characters, each represents a position on the board. The order of the characters in the file is the same order that they would be printed to the screen, i.e. left-right then back-front then top-bottom (though this is not important). If the character is the character '0' then the place is empty. A '1' is an X and a '2' is a O. Assume that you are always X and your opponent is always O. A single move should take no longer than five seconds on the PCs in the lab. Programs that take longer than this may be disqualified. Your program should be written in standard C or C++ do not use any non-portable code, I need to recompile all your programs on my machine. If you want to use another language, let me know first, Haskell, Pascal and Prolog should be OK though. Use the checkpos program as a starting point - it calculates all the possible winning lines.
The website (cs-alb-pc3.massey.ac.nz) contains the following files.
checkpos.c --- check for a win and
print out a board position.
mymove.c --- allows you to play by hand.
swap.c --- swaps sides allowing two programs two play each other.
martin.exe --- my solution to the assignment.
empty --- an empty board.
run.bat --- a batch file to play my program against itself.
Your source code must be in a single file. Instructions on how to submit your program are on the web page. Your programs will be played against each other and marked based only on their performance. Unless your program does not compile or I suspect it is too similar to another, I will not even look at the code. Note that the batch file you have been given does not check to see if a program has cheated. The one I use will do this, so you need to carefully check that your program always makes valid moves otherwise it will lose a lot of games.
M Johnson 2008