I'm not sure the internet needs yet another TicTacToe game. This was mostly an attempt to write a longer JavaScript program for my own benefit.

The artificial intelligence chooses from an opening book for the first move, then builds the complete game tree for subsequent moves. it should therefore always choose the "least bad" move, assuming a perfect opponent.

The code is available at ??. I used Underscore.js for syntactic sugar, and jQuery and jQuery UI for the eye-candy.