This is the world's most complexly coded tic-tac-toe implementation. I approached the problem way too generally, and was new enough to Java to do a really bad job with it.

On the bright side, it does play correctly and doesn't lose. Well, now it doesn't. Peter Benoit pointed out a bug more than a year ago that I finally got around to fixing (15 Oct 2004).

OK, this time it really doesn't. I hope. Adrien Briand pointed out another strategy that won against the old code that doesn't win anymore (16 Nov 2005). Apparently people are playing against it. Unfortunately they're also beating it.

Fine. There are only 3 tricky games when you start as X outside the middle and I lost to all of them. Thinking about the problem is always right and just hacking around with java is always wrong. Thanks to Ken Ferguson for pointing out the third game.

It's not pramaterizable, and if you make it too small (less than 200 wide on my machines), it's impossible to pick sides at the start. And, of course, it's not an interesting game. Still, it may be something to fidget with during a download.

Here's an example of how to put it up:

Stupid JavaTM Trick
	    <object codebase="/~faber/java/ttt"
	    archive="ttt.jar" height="100" width="200">
	      Stupid Java<sup><small>TM</small></sup> Trick

Feel free to play with it. A jar file is available. Don't sell it in whole or in part without asking me (who'd buy it??). If you use it on your web pages, a link back here would be nice. And I always enjoy hearing that someone's using it.

Valid XHTML 1.0!
This page written and maintained by Ted Faber
Please mail me any problems with, or comments about this page.
PGP public key