Back to BlogBrain Training & Logic

How to Play Tic-Tac-Toe, and How to Win (or Never Lose)

The rules of tic-tac-toe, the best first move, the only safe replies, and how to win more often, from all 255,168 possible games worked out by computer.

How to Play Tic-Tac-Toe, and How to Win (or Never Lose)

Everyone learns tic-tac-toe as a child, and most people stop playing once they notice that good games always end in a draw. That part is true. But "always a draw" only holds if both players play perfectly, and most people do not. Against a real opponent, where you put your first X makes a big difference.

We worked out every possible game, all 255,168 of them, and the best move in every position. Then we measured how often each opening wins against a typical player. This guide covers the rules, the numbers, and the simple moves that win more games without ever risking a loss.

How to play tic-tac-toe

Tic-tac-toe, called noughts and crosses in Britain, needs a pencil, paper and two players.

  1. Draw a grid of two lines down and two across, making nine squares.
  2. One player is X and the other is O. X goes first.
  3. Take turns writing your mark in any empty square.
  4. Get three in a row to win: across, down or corner to corner.
  5. If all nine squares fill up and nobody has three in a row, the game is a draw. Players often call this a "cat's game".

Left: a tic-tac-toe grid labeled by square type. The four corners are each part of 3 winning lines, the four edge squares 2, and the center 4. Right: a finished game where X has three in a diagonal from top left to bottom right.

There are only eight ways to win: three rows, three columns and two diagonals. The squares are not equal. The center is part of four of those lines, each corner is part of three, and each edge square, the ones in the middle of a side, is part of only two. Keep that in mind, because it explains almost everything below.

Every possible game

Tic-tac-toe is small enough to work out completely. If you count every legal sequence of moves, including foolish ones, there are 255,168 different games.

Bar chart of all 255,168 possible tic-tac-toe games by how they end: X wins on move 5 in 1,440, O wins on move 6 in 5,328, X wins on move 7 in 47,952, O wins on move 8 in 72,576, X wins on move 9 in 81,792, and 46,080 end in a draw.

X wins 131,184 of them, O wins 77,904, and 46,080 are draws. Going first is a real advantage: if both players picked squares at random, X would win 58.5% of games, O 28.8%, with 12.7% drawn.

Those games pass through 5,478 different board positions. Many are the same board turned or flipped, and once you count those as one, there are only 765 positions in the whole game. That is why a computer, or a patient person with paper, can know the best move in every one.

The answer, as most people suspect: with perfect play from both sides, every game is a draw. Neither player can force a win. So the real question is how to win against someone who is not perfect, and how to make sure you never lose.

Where to put your first X

To test openings fairly, we used a computer opponent that plays the way many people do. It takes a win if it sees one, blocks you if you are about to win, and otherwise picks a square at random. We call it the casual player. Then we worked out, exactly, how often X wins with the best play after each first move.

Three boards showing X's first move in a corner, on an edge and in the center. Against a casual player who takes wins and blocks but otherwise moves at random, the corner wins 92.7% of games, the edge 84.9% and the center 83.3%. X never loses with best play.

Start in a corner. Against the casual player, a corner opening wins 92.7% of games. The center wins only 83.3%, and an edge 84.9%. None of them ever loses with careful play afterwards.

That surprises people, because the center sits on the most lines. The reason is the reply. After a center opening, O has four safe answers, the four corners, and a casual player finds one of them half the time. After a corner opening, O has only one safe answer, and most players miss it.

The only safe replies for O

This is the most useful thing to know as the second player. For every first move by X, we checked which replies by O still lead to a draw with perfect play, and which are already lost.

Three boards showing which first replies keep the draw for O. After X takes a corner, only the center draws; the other 7 squares lose. After X takes an edge, 4 replies draw. After X takes the center, the 4 corners draw and the 4 edges lose. In all, 48 of the 72 possible first-move-and-reply pairs are already lost for O.

  • If X starts in a corner, you must take the center. It is the only one of the eight replies that does not lose against a perfect player.
  • If X starts in the center, take a corner. Any edge square loses.
  • If X starts on an edge, you have four safe replies: the center, the two corners next to X, and the edge square opposite X.

Of all 72 combinations of a first move and a reply, 48 already lose for O. That is two out of three. Most tic-tac-toe games are decided on the second move, even though nobody notices until three moves later.

How games are won: the fork

Almost every win in tic-tac-toe comes from a fork: one move that makes two lines of two at the same time. Your opponent can block only one, so you complete the other.

Three boards showing a fork. X holds two opposite corners with O in the center. O takes the top right corner, which threatens the other diagonal. X blocks in the bottom left corner, and that one move makes two lines of two at once: down the left side and along the bottom row. O can only block one, so X wins.

Here X has two opposite corners and O holds the center. O takes another corner, which looks natural but is a mistake: X must block the diagonal, and the blocking square happens to start two lines at once. In this position O's correct move was an edge square, which forces X to block instead of attack.

Corners are the best squares for forks because each one is on three lines. That is why a corner opening is so strong against anyone who does not reply in the center.

Tips that come straight from the numbers

  • Going first, start in a corner. It wins 92.7% against a casual player, against 83.3% for the center, and it never loses.
  • Going second, answer a corner with the center and the center with a corner. Every other reply to those openings loses to good play.
  • Look for forks. Before each move, check whether any empty square would give you two lines of two at once.
  • Block forks, not just lines. When your opponent has two corners and you hold the center, take an edge, not a corner.
  • Expect a draw against a good player. With perfect play from both sides, every game ends in a draw.

How we checked

A short program walked through every legal game from the empty board and counted how each one ended. It then gave every position its value with perfect play (win, draw or loss for the player to move) by working back from the ends of the games. For the opening tests, X picked the move with the best chance to win against each opponent, but only among moves that never risk a loss, and we added up the exact chances over every way the opponent could reply. Nothing was sampled at random, so the numbers are exact. The code is in our site's repository.

Where tic-tac-toe came from

Games of three in a row are very old, and versions with movable pieces were played long before paper was cheap. By the 1800s the pencil and paper version was well known, and in Britain it is still called noughts and crosses. It also has a place in computer history. In 1952 A. S. Douglas wrote OXO, a noughts and crosses game for the EDSAC computer at the University of Cambridge, and it is often named as one of the first video games.

Frequently asked questions

Can you always win tic-tac-toe? No. With perfect play from both players, every game is a draw. You can win against a player who makes a mistake, and you can always avoid losing.

What is the best first move in tic-tac-toe? A corner. All three openings draw against perfect play, but against a typical player a corner wins most often: 92.7% of games in our test, against 83.3% for the center.

How do you never lose at tic-tac-toe? Take a win if you have one, block your opponent's two in a row, and watch for forks. As the second player, answer a corner with the center and the center with a corner.

How many possible tic-tac-toe games are there? 255,168 if every legal sequence of moves counts, passing through 5,478 board positions, or 765 once turned and flipped boards are counted as one.

Who has the advantage, X or O? X. Going first wins more often against imperfect players, though perfect play is still a draw.

Play tic-tac-toe now

Try the numbers for yourself. Choose X to go first or O to go second, and pick an opponent: Easy plays at random, Medium is the casual player from this article (it wins and blocks but otherwise picks at random), and Unbeatable plays perfectly, so the best you can do is a draw. Tick "Show perfect play" to color every empty square by what it leads to: green wins by force, yellow draws, and red loses. It is a quick way to see why the center is the only safe reply to a corner.

Loading the game…

If you like this kind of game

Tic-tac-toe is the smallest game that a computer can solve completely. Minesweeper and 2048 are much bigger, so we tested them with computer players instead, and Yahtzee shows how to work out exact odds when dice are involved. For more games that reward thinking ahead, see our list of the best brain training and logic games.

Share this post