Tic Tac Toe Algorithm
Now we know how to detect, grab, and move a game piece. Next we need to learn how to play Tic Tac Toe. The associated solution, TicTacToe.sln, is located in the TicTacToe folder (http://code.google.com/p/robotic-tic-tac-toe-lynxmotion/source/browse/trunk/#trunk/TicTacToe). The game algorithm code in the TicTacToe.Logic project is inspired by the code that Jonathan Haywood posted on his blog (Tic-Tac-Toe Using Minimax and ASP.NET). Thanks Jon! Please see Jon's blog for additional information about the Minimax algorithm.
As a simple way to test the code I added a small WinForm application that allows a user to play against the computer (project TicTacToe.UI). The user makes a move by clicking on the desired field. The user's moves are drawn as crosses, the computer's moves as blue circles:
I only used the app for testing purposes and as such the app is not polished at all.