Home › Games & Fun › Tic-Tac-Toe (○×)

How Many Possible Tic-Tac-Toe Games Are There?

Tic-tac-toe has only nine squares, yet people who try to count its games often come up with very different answers. The confusion comes from counting different things: ways to fill a board, orders of moves, games that end early, or positions that are the same once you rotate the board.

This guide gives each of those numbers and explains where it comes from. Every figure here was checked by a short computer program that plays out every legal game. It ends with how to explore the game yourself in this Tic-Tac-Toe game.

The short answer

If the first player is X, the second is O, and a game stops as soon as someone gets three in a row or the board fills up, there are exactly 255,168 different possible games. Here, two games are different if the moves were played in a different order.

These counts treat every legal game as equally likely, which real players are not. They do not mean the first player wins about half of real games; they mean that random moves favour the first player.

The bigger numbers you may have seen

362,880

This is 9 x 8 x 7 x ... x 1, written 9!, the number of ways to fill all nine squares one by one. It is too high, because many games end before the board is full: once someone has three in a row, no more moves are played.

19,683

This is 3 to the power 9: each of the nine squares can be empty, X or O. It counts all patterns of marks, including impossible ones such as a board with five Xs and no Os.

Positions rather than games

Many different move orders arrive at the same board. Counting boards instead of games gives much smaller numbers:

The board has eight symmetries: four rotations, each of which can also be mirrored. That is why opening theory only needs to consider three first moves: a corner, an edge or the centre.

How long games last

The fastest possible win takes five moves: three by X and two by O. Of the 255,168 games:

Why perfect play is a draw

Because the game is so small, a computer can search every position and work out the best move from each one. That search shows the starting position is a draw: if neither player makes a mistake, nobody wins. Tic-tac-toe is therefore called a solved game.

The search also shows which first replies are safe. After a corner opening, only the centre avoids defeat. After a centre opening, any corner is safe and any edge loses. Those results are the basis of the strategy in how to win at tic-tac-toe.

Counting it yourself

If you write programs, counting the games is a classic exercise. Write a function that, for the current board and player, checks for a win or a full board; if the game is over, count one game, otherwise try each empty square in turn for the current player and call itself on the result. Run from an empty board, it visits every one of the 255,168 games in a few seconds at most on a modern computer. Storing each board you visit in a set gives the 5,478 positions.

Exploring the game in this Tic-Tac-Toe game

Tic-Tac-Toe (○×) is a two-player game for one screen. ○ always moves first, so ○ plays the role of X in the counts above.

  1. Tap any empty square to place a mark; turns switch automatically.
  2. The game checks all eight lines after every move and announces the winner, or a draw when the ninth square fills.
  3. Press Play Again to try a different opening and see how the game unfolds.

It is also available on iPhone and Android.

Frequently asked questions

How many possible tic-tac-toe games are there?

255,168, counting every legal sequence of moves that ends with a win or a full board.

How many tic-tac-toe board positions are there?

5,478 positions can occur in legal play, or 765 if rotations and reflections are counted as one.

Why do some sources say 362,880?

That is 9!, the number of ways to fill all nine squares in order. It ignores games that end early.

What is the minimum number of moves to win?

Five: the first player's third move can complete a line.

Does the first player have an advantage?

With perfect play the game is a draw, but the first player has more ways to win and, in random play, wins far more games.