QTNest logoQTNest
games

Tic Tac Toe Is a Solved Game: How to Never Lose It Again

With both players playing correctly, every game of tic tac toe is a draw. Learning why takes about ten minutes, and it turns the game from luck into a short, complete lesson in looking one move ahead.

Tic tac toe is the smallest game that is worth analysing and the largest one most people can hold entirely in their head. There are 255,168 possible games. The first player wins 131,184 of them, the second wins 77,904, and 46,080 end in a draw — but those counts include every blunder either side could make. Between two players who know what they are doing, the result is always the same: a draw.

That makes it a strange game to be good at. You cannot win against competent opposition; you can only avoid losing, and wait for a mistake. Which is precisely why it is the best first lesson in board-game thinking there is.

The one thing that decides every game: the fork

A fork is a move that creates two threats at once. Your opponent can block one of them, and then you complete the other. Every win in tic tac toe that is not a gift comes from a fork, and every loss comes from allowing one.

That reframes the whole game. Blocking a single three-in-a-row is easy and obvious; the real skill is noticing the move that will produce two threats next turn and stopping it before it exists. Once you see forks, tic tac toe stops being a race to three and becomes a game about the move before that.

It also explains the shape of good play: corners matter because each corner sits on three lines, and the centre matters because it sits on four. Squares on more lines make more forks possible.

Playing first: take the centre or a corner

Opening in the centre is the strongest practical choice. It sits on four of the eight lines, and against anything but an accurate reply it leads to a fork quickly. The only non-losing answer is for your opponent to take a corner; if they take an edge instead, you can force a win.

Opening in a corner is the sharpest choice, because it gives the second player only one non-losing reply — the centre — and most people do not find it. Take a corner against an inexperienced opponent and you will win more often than from the centre, simply because the correct response is less obvious.

Opening on an edge is the weak move. It sits on only two lines, and it gives the second player several safe answers.

Playing second: the reply is everything

The whole of second-player strategy is one rule: if the first player took the centre, take a corner; if they took a corner, take the centre. Any other reply can be beaten.

That is not folklore, it is exhaustive. Search the position to the end of the game and every alternative second move loses against best play. It is also the single most useful fact in this article, because playing second is the situation where people actually lose.

After that reply, the rest follows the same three priorities in order: complete three in a row if you can; block theirs if they can; otherwise take the square that stops a fork, preferring one that creates a threat of your own. A player who applies those three rules in that order will never lose a game of tic tac toe.

What an unbeatable opponent actually does

Computer opponents at this game do not use the rules above. They search: try every legal move, then every reply, all the way to the end of the board, and score each line as a win, a loss or a draw. Nine squares means at most 362,880 sequences to walk, which is nothing for a computer, so the search can be complete rather than approximate.

Complete search is why such an opponent cannot be caught out by an unusual opening — there is no pattern list to fall outside of. Our tic tac toe uses exactly that on its unbeatable setting, and we verified it the only way that settles the question: by playing every legal human line of play against it, going first and going second. It never lost one.

A small refinement matters for how it feels to play. When several moves all win, the search prefers the one that wins soonest; without that, an engine will happily take an extra three moves to finish, which reads as toying with you rather than playing well.

Making a computer opponent that is beatable is the harder design problem. Searching less deeply is not enough, because most of tic tac toe is taking the win in front of you and blocking theirs, and a shallow search still does both. What actually makes an easy setting winnable is letting it sometimes fail to block — which is what ours does, while never passing up a win of its own, because an opponent that walks past a completed row reads as broken rather than as gentle.

Why you cannot win, and what to do about it

Tic tac toe was solved long before computers, in the sense that the drawn result was well understood. What a computer added was certainty about every branch. There is no clever opening left to find and no trap that works on someone who blocks properly.

For two people who both know the strategy, that means the interesting part of the game is over. The draws pile up, and the game has finished teaching. This is normal, and it happens to every game small enough to be solved — it is a property of the game, not a failure of the players.

The natural next step is a board where good play is not a settled question. Connect four is the same idea — take turns, make a line — on a seven-by-six grid, with one extra rule that changes everything: your counter falls to the bottom of the column, so every move you make builds the platform your opponent plays from.

Connect four has over four and a half trillion legal positions. It was solved independently by two researchers in 1988, and it is a first-player win with perfect play, starting in the middle column. But nobody can hold that solution in their head, which is exactly what makes it still worth playing — and why threats, double threats and the squares above them are things you have to work out at the table rather than recall.

Teaching it to a child

Tic tac toe is often a child’s first strategy game, and there is a specific moment worth engineering: the first time they block you on purpose. Before that they are placing marks; after it they are playing.

The way to get there is to threaten obviously and slowly, and let them notice. Then, once blocking is reliable, start setting up forks and let them lose to one a few times. The lesson that lands — look at what my move lets them do next — is the one that transfers to every other game they will play.

An easy computer opponent is useful here because it makes both mistakes at a manageable rate: it sometimes fails to block, so a child can win, and it always takes its own win, so a child learns that leaving a threat open has a cost.

Play it

Our tic tac toe has the unbeatable search plus easy and medium settings that can genuinely be beaten, and a two-player mode on one device. The starting side alternates between games, because the first move is an advantage and a fair run of games has to share it.

If the computer is not the point, the same page has a two-player mode with no opponent in it at all — pass the phone, keep score, and watch the draws start to accumulate as you both get better. That is the game telling you it is time to move up to connect four.

Related tools and games