Please also check this
What is TicTacToe ?
Tic-tac-toe, also spelled tick tack toe, and alternatively called noughts and crosses, hugs and kisses, and many other names, is a pencil-and-paper game for two players, O and X, who take turns marking the spaces in a 3×3 grid, usually X going first. (source: http://en.wikipedia.org/wiki/Tic-Tac-Toe)
Now I will present a simple code to create Tic Tac Toe AI.
I will create one java file: TicTacToeAI.java
it will initialize all value in board to 0.
if position (i,j) is outside the boundary it will return EMPTY
My winning move definition is one single move that lead to victory.
I calculate the best move based on this priority:
1. lead to win
2. prevent enemy to win
3. center position
4. first available position