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.
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.
Christopher Nelling has compiled binaries for AmigaOS and MorphOS. You can get the AmigaOS version from the downloads section of this site, and the MorphOS version from http://privat.schlund.de/t/thezone/cn/files.html.
You can download the software from the project page.
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.
As of version 1.2.1 you can specify the size as a command line parameter to the game.
The binary is called tictactoe.
tictactoe [--help] [--debug] [O|X] [size]
All other options are ignored without an error.
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. You might use this for example if you want to write a gui wrapper for this program. You can popen it and capture its streams.
If X wins, returns 1, if O wins, returns -1.
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.
tictactoe is written by Philip S Tellis <bluesmoon [AT] users.sourceforge.net>
tictactoe is Copyright (c) 2001-2002 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.