Play Tic-Tac-Toe Online
The classic noughts and crosses game. Place your marks and be the first to get three in a row. Challenge the AI or play with a friend.
Created by Brian Hamilton
How to play Tic-Tac-Toe
Take turns marking squares. Three in a line wins.
- Three in a row, column or diagonal wins.
- If the board fills with no line, the game is a draw — which is what perfect play always produces.
- Games are won by making a fork: two threats at once, so only one can be blocked.
- Open in a corner: only one of the eight replies saves your opponent, against four if you open in the centre.
- The Unbeatable setting has been proved never to lose, across every line of play that exists.
Controls: tap any empty square to place your mark. Choose the AI difficulty, or two-player mode, above the board.
Open in a corner, not the centre
Everyone is told to take the middle. Against someone who knows what they are doing it makes no difference — every opening draws with perfect play. Against someone who does not, the corner is by far the most testing move on the board.
Solve the game and count. If you open in a corner, exactly one of your opponent's eight replies saves them: the centre. Get anything else and you have a winning position. If you open in the centre, four of the eight replies draw. An edge opening also leaves four.
Every win is a fork
Nobody has ever won a game of tic-tac-toe by building a line their opponent failed to notice. Games are won in exactly one way: by reaching a position with two threats at once. One gets blocked, the other wins.
So the whole game reduces to two questions, asked every single turn. Can I make a move that creates two lines needing one square each? And — more urgently — can my opponent?
The defensive version is the useful one, because forks are much easier to walk into than to spot. Before you play, look at your opponent's marks and ask which empty square would give them two threats. If there is one, that square is where you must play, whatever else the board is offering.
The order of priorities
Play these in order and you will never lose:
1. Win, if you can. Two of yours in a line with the third square empty.
2. Block, if they can. The same, in their colour.
3. Make a fork. A square that creates two threats at once.
4. Stop theirs. If they threaten a fork next move, take that square — or force them to respond to a threat of yours instead, which is often stronger, because it makes them spend their move on defence.
5. Centre, then an opposite corner, then any corner, then an edge. The centre sits on four lines, a corner on three and an edge on two. When nothing is forced, take the square that belongs to the most lines.
Answering the corner opening
Worth memorising, because it is the one position where a single mistake decides the game: if your opponent opens in a corner, play the centre. Not the opposite corner, not an edge. The centre. It is the only reply of the eight that draws, and the measurement above is the whole argument.
The mirror of that: if you open in the centre and they take a corner, the game is still drawn, but you now have to keep finding the right square. Openings that leave your opponent one saving move put the burden on them instead.
What was verified on this page
Tic-tac-toe is small enough that nothing here needs to be sampled. Win detection was checked against an independently written scanner on all 19,683 possible arrangements of marks — every board that can be drawn, legal or not. There are 255,168 complete games and 4,520 distinct position-and-turn states, and solving from the empty board confirms the classic result: with perfect play the game is drawn.
The page claims its Unbeatable setting “will never lose”. That was proved rather than tested. The AI's move is deterministic, so the whole game tree was walked with the opponent branching over every legal reply at every turn: 73 complete lines with the AI playing first, 569 with it playing second, and not one loss in either. There is no sequence of play that beats it.
One real weakness turned up and has been fixed. The AI scored every win as worth the same, whenever it arrived — so it could decline a win on this move in favour of one three moves later. It never lost by doing so, but it would visibly ignore an obvious winning square, which looks like a bug because it behaves like one. Measured across every reachable position it was taking only 87% of its immediate wins. The score now falls with depth, so a faster win outranks a slower one, and it takes all 276 of them — while still, re-proved by the same exhaustive walk, never losing.
| Difficulty | Perfect player wins | Draws | AI wins |
|---|---|---|---|
| Easy | 78% | 22% | 0 |
| Medium | 39% | 61% | 0 |
| Unbeatable | 0% | 100% | 0 |
Medium is the interesting one. It plays the priority list above but throws in a random move a quarter of the time, and that is enough to lose 39% of games to perfect play while still never actually winning one. Tic-tac-toe punishes single mistakes and rewards nothing else.
A game that is worth having played out
Noughts and crosses is where most people meet the idea that a game can be finished — that there is nothing left to learn, only whether both players know it. Children work this out for themselves somewhere around eight, and stop playing.
It is also the standard first exercise for game-playing programs, for exactly the reason above: the whole tree fits in a fraction of a second, so the algorithm that beats grandmasters at chess can be seen working, in full, on something you can check by hand. Everything on this page — every claim, every count — was computed by walking that tree to the end.
More games like this
If you like games decided by the threat that cannot be answered, try these:
4 in a Row
Classic strategy — drop discs and connect four in a line. Play vs AI or a friend.