Hard AI uses the Minimax algorithm — it never loses!
About Tic Tac Toe
Tic Tac Toe — noughts and crosses — is played on a three by three grid, with two players alternating marks and the first to line up three in a row winning. Almost everyone learns it as a child, and almost everyone eventually notices the same thing: played correctly by both sides, it always ends in a draw.
That property makes it more interesting than it first appears. Tic Tac Toe is a "solved" game, meaning the complete outcome is known for perfect play from any position, and it is the standard first example when teaching game-tree search and the minimax algorithm in artificial intelligence. There are only 255,168 possible complete games, small enough to enumerate entirely, which is precisely why it works as a teaching example where chess or Go cannot. Here you play against the computer, so your realistic goal is to force the draw and pounce on any mistake.
How to Play Tic Tac Toe
- Click any empty square to place your mark.
- The computer takes its turn immediately after yours.
- Line up three of your marks in a row, column or diagonal to win.
- If the grid fills with no line of three, the game is a draw. Play again to try a different opening.
Tips & Strategy
- Take the centre if it is free. It sits on four of the eight possible winning lines, more than any other square.
- Corners beat edges. A corner belongs to three winning lines, an edge to only two.
- Always check for two threats at once. Creating a position where you threaten two lines simultaneously is the only way to force a win against a defender who is otherwise playing correctly.
Frequently Asked Questions
No. Tic Tac Toe is a solved game and correct play by both sides is always a draw. You can only win if your opponent makes a mistake.
The centre. It participates in four of the eight winning lines, which is more than any corner or edge.
It is an advantage in the sense that only the first player can force a win against imperfect defence. Against perfect defence it still ends in a draw.
The full game tree is small enough to search exhaustively, which makes it the standard worked example for minimax and game-tree search before moving to games too large to solve.