Saturday, January 7, 2012

How to win at Tic Tac Toe

I couldn't sleep the other nite. As a result, I ended up thinking about the strategy of Tic Tac Toe. There really isn't a whole lot to think about, but in my head I went through all of the possible game states. Not a difficult feat since the game is both vertically and horizontally symmetrical. In the end, I was able to distill it down to a few basic principles. The center is the most valuable resource in the game. Always go for that. It is part of 4 possible ways to win. Next are the corners. Each of them are part of 3 possible ways to win. The middle outside spots are the worst. They are only able to help you win in 2 ways.

3 | 2 | 3
2 | 4 | 2

3 | 2 | 3

In practice then, if you are the X then you should start the game by taking the middle. If you don't you are likely to lose. The "O" player should then take a corner. If the "O" player takes a middle outside square, then the "X" player should take the corner square next to the spot taken by the "O" player. The "O" will be forced to block the potential cross victory position. The "X" player can now take a middle spot that connects his other two "X" spots, which will create a dual possibility for the win. He can also take any remaining corner spot for a dual win option on the next play.

If the "O" player is wise and takes a corner spot, the game is probably a draw. Almost any move from here creates a domino effect of blocking moves. It should be a draw. However, if the "X" player takes the opposite corner spot, then the "O" player has plenty of choices where the outcome isn't obvious. If they take an adjacent middle outside spot on the next move, then the "X" player may have to block an "O" victory, however the blocking will create the dual win situation for the "X" player. If they take any other middle outside spot, then the "X" player can setup the dual victory as well by taking the most open corner location.

The game does have a few non-obvious traps. If you are the "X" player you CAN win even against a more seasoned player by thinking about the game in terms of spot values.