Tic Tac Toe

Play Tic Tac Toe against the computer.

You're X, the computer is O. Tap any empty square to play — the computer plays a perfect strategy, so a draw is a good result.

Your move.

Why the computer never loses

Tic-tac-toe is small enough that a computer can look all the way to the end of every possible game before making a single move — a technique called minimax, where the AI assumes you'll always play your best response and picks whichever move guarantees the best outcome even against that. That's the entire trick: it isn't reacting to you, it already knows how every line of play ends.

With perfect play from both sides, tic-tac-toe always ends in a draw — a fact mathematicians settled with certainty a long time ago, since the whole game tree is small enough to check completely. That's why forcing a draw against this computer, rather than expecting a win, is genuinely the correct goal.

For your own game against less perfect opponents, take the center first if it's open, then a corner over an edge — center and corners each sit on more possible winning lines than an edge does, which is the actual reason that opening advice holds up.

Common questions

Is the computer beatable?

The computer plays a perfect strategy, so the best possible outcome against it is a draw — the same as against a perfect human opponent.

Who goes first?

You always play X and move first, then the computer responds as O.

Why does the computer never make a mistake?

It searches every possible sequence of moves to the end of the game before choosing — see the paragraph below for how that actually works.