tictactoe is an implementation of the very common game that we learn to play as kids. There are two pieces - X and O. O always plays first. There are no real rules to this game, except that the first person to complete a line (row, column or diagonal) from one end to the other is the winner. Diagonals MUST pass through the centre. The size of the board is configured at compile time by setting the SIZE macro. Only odd sized boards (3, 5, 7) will work. Don't even bother with even sized boards, I don't know what will happen. What's so different about this implementation? Well, it doesn't use lookahead like most other implementations would. It basically places its piece on all available positions, and checks if the board arrangement `looks' good or not. It picks the best looking option. This implementation should never lose, on any board >= 3X3, although it has been known to win on occassion. If it does lose, it should be possible to fix it just by changing the scores for each of the rules. Try running it with the --debug switch turned on for diagnostics. The system is based on six rules that I will document later, but can be found in the source. The first two - win if possible, and block if opponent can win may be removed in a future version if the other rules seem to cover them. INSTALL ------- To install the game, run make, and make install as root. To uninstall it, run make uninstall. You may want to tweak the Makefile to change paths and compiler directives. The default size is 3, pass the variable SIZE to the Makefile to whatever you want the size to be: SIZE=5 make would compile a board with size 5x5. The binary is called tictactoe. SUMMARY ------- tictactoe [--help] [--debug] [O|X] --help prints a help message, and then runs the game --debug prints a trace of what the game is doing O tells the computer that you want O, ie, you want to play first this is the default X tells the computer that you want X, ie, you want to play second All other options are ignored without an error. OUTPUT ------ The board and prompts are printed to stdout. Debugging info and errors are written to stderr. Input is taken from stdin. If the output device is not a tty, then prompts are sent to stderr, and only the board is printed to stdout. RETURN VALUE ------------ If X wins, returns 1, if O wins, returns -1. DIAGNOSTICS ----------- If the program should lose, or if you just want to see what it is doing, then run it with the --debug switch turned on. CAVEATS/BUGS ------------ When prompted for a row/column, do NOT enter non-numeric data. I don't know what will happen if an even sized board is compiled. AUTHOR ------ tictactoe is written by Philip S Tellis command line board size patch by Jesse Perry COPYRIGHT & WARRANTY -------------------- tictactoe is Copyright (c) 2001 Philip S Tellis. No warranty on this software, I am not liable for any damage that it may do to you or your computer. Additionally, this software is distributed under the terms of the GNU General Public Licence. A copy of this is available in the file Copying distributed with this software.