49Games

Why tic-tac-toe is always a draw

Tic-tac-toe is small enough to solve. Play a machine that never errs, see which first moves are safe, count every game that can be played and find the best move in a position.

Chalk and slate

A game with a known ending

Tic-tac-toe is called noughts and crosses in Britain. Two players take turns to mark a square on a grid of three by three. The first to make a line of three wins. If the grid fills with no line, it is a draw.

The game is small enough that a computer can look at every position. It finds that if both players make no mistakes, the game is always a draw. Four things to try. Play a machine that never errs. See which first moves are safe. Count every game that can be played. Find the best move in a position. Without a script each part shows one picture.

Slate one

Play the machine

This machine looks ahead to the end of the game from every position, so it never makes a mistake. Choose to play first or second and try to beat it. You can only win if the machine errs, and it does not.

The machine picks at random among its equally good moves, so the games differ. The score below counts your games on this page only.

A finished game that nobody won. The machine cannot be beaten, so a draw is the best you can get.

Your games: 0 won, 0 drawn, 0 lost.

Slate two

The first moves

Cross moves first. Pick a square for the cross and see what each reply of the nought leads to, if both play perfectly after that. A square marked draw keeps the game level. A square marked loss hands the win to cross.

Many people think the centre is the only good first move. With perfect play every first move still gives a draw. What changes is how many replies hold it. After a corner, the nought has one safe reply. After the centre or an edge, four.

Press a square to open there.

Cross opens in the top left corner. The nought has 1 reply that draws and 7 that lose.

Slate three

Count every game

The game has nine squares and ends after at most nine moves. A game ends when a line is made or the grid is full. Counting all the ways to play gives 255,168 different games. They end in 131,184 wins for cross, 77,904 wins for nought and 46,080 draws.

Many of the positions in these games are the same position reached in different orders, and many are turned or mirrored copies of each other. There are 5,478 positions that can arise, and 765 when turned and mirrored copies count as one. Slide the number of moves to see how many games end there.

  • Move 51,440
  • Move 65,328
  • Move 747,952
  • Move 872,576
  • Move 9127,872

255,168 games in all: 131,184 won by cross, 77,904 won by nought and 46,080 drawn. No game ends before move 5.

Games, positions and what they are worth
WhatNumber
Different games255,168
Positions that can arise5,478
Positions if turned and mirrored copies are one765

Press the button and your browser will play out every game.

Slate four

Find the best move

Perfect play is one idea: for each move, ask what the other player can do next, and choose the move whose worst case is best. Computers do this by looking at every continuation, which is called minimax.

Five positions, from easy to hard. Pick a square. The page says whether that move wins, draws or loses with perfect play after it. A move that makes two threats at once is called a fork, and the last two need one.

Cross to move. With perfect play after each move: middle right draws, bottom middle draws, bottom right wins.

Key takeaways

  1. If both players make no mistakes, tic-tac-toe is always a draw.
  2. There are 255,168 different games, and 5,478 positions that can arise. Counting turned and mirrored copies as one leaves 765.
  3. Cross wins 131,184 of the games, nought 77,904, and 46,080 are draws. These count every possible game once. They say nothing about who wins in real play.
  4. Every first move gives a draw with perfect play. The corner is the best try against a player who errs, because most replies lose.
  5. A computer plays perfectly by looking at every continuation and choosing the move with the best worst case.

Sources

Most of these sites could not be opened while this page was written, so the facts were checked through search results that quote them. That the game is a draw with perfect play, 255,168 games, 5,478 positions, 765 positions up to turning and mirroring, the split of 131,184 wins for cross, 77,904 for nought and 46,080 draws, and the idea of minimax each appeared in at least two places. The page also computes the counts itself from the rules and they match. Sources disagree on the number of games up to turning and mirroring, so the page gives no such figure. The advice about which opening to choose is a general observation, not a rule, and the page says what it counts.