Skip to content
tools.best

Browse all tools

Tic-Tac-Toe

Play tic-tac-toe against the computer or a second player on the same device: X moves first, and three in a row wins.

Runs in your browser. Nothing you enter is sent to a server. Sources: Wikipedia Updated

Your turn. You are X.

X wins: 0 O wins: 0 Draws: 0

How to play tic-tac-toe

Two players take turns to mark one empty square on a 3 × 3 board. X goes first. The first player to get three of their marks in a line, across, down or diagonally, wins. If all nine squares fill up and nobody has a line, the game is a draw.

Choose your opponent above the board. Against the computer you play X and it plays O. With a second player, pass the device or the mouse back and forth: X moves first, then O.

Click or tap a square to mark it. On a keyboard, press Tab to reach the board, use the arrow keys to move between squares, and press Enter or Space to mark the one in focus.

How the computer chooses its move

The computer follows five rules, in this order, and takes the first one that applies:

  1. If it has two in a line and the third square is empty, it takes that square and wins.
  2. If you have two in a line and the third square is empty, it blocks you.
  3. If the center is empty, it takes the center.
  4. If a corner is empty, it takes one of the empty corners at random.
  5. Otherwise it takes one of the remaining squares at random.

It looks only one move ahead. It never loses to a simple two-in-a-row, but it does not plan a double threat or see yours coming.

How to beat the computer at tic-tac-toe

Because of that, there is a sequence that beats it every time:

  1. Take a corner. The computer takes the center (rule 3).
  2. Take the opposite corner. Nothing needs blocking, so the computer takes one of the two free corners (rule 4).
  3. It now has two on a diagonal. Take the last free corner, which blocks that diagonal.
  4. You now have three corners and two open lines along the edges. The computer can block only one (rule 2).
  5. Take the other and you have three in a row.

A stronger opponent would answer step 2 with a side square instead of a corner. If you want an even game, play a friend in two-player mode.

How many games of tic-tac-toe are possible

We counted every possible game at build time, move by move, stopping each game when someone wins or the board is full. There are 255,168 games: X wins 131,184 of them, O wins 77,904 and 46,080 end in a draw.

Tic-tac-toe board showing how many of the 255,168 possible games start with X in each square: 27,732 for each corner, 29,592 for each edge and 25,872 for the center. X wins 131,184 games, O wins 77,904 and 46,080 are draws.
A first move in the center leads to the fewest possible games: 25,872, against 29,592 for an edge.

The search also scores every position for best play from both sides. Every one of the nine first moves then ends in a draw, which matches the description of tic-tac-toe as a solved game in the Wikipedia article on tic-tac-toe.

If no game ended early, the nine squares could be filled in 9! = 362,880 orders. That is the arrangements formula of the word combination generator, n! ÷ (n − r)!, with n and r both 9. Wins before the board is full bring the number down to 255,168.

Tic-tac-toe score and new games

The score under the board counts wins for X, wins for O and draws. New game clears the board and keeps the score. Reset scores clears both.

Changing the opponent also starts a new game and sets the score back to zero, so the tally always refers to one opponent. Nothing is stored: the score is gone when you reload or leave the page, as the privacy page explains for every tool. The game sits with the other everyday tools.

Tic-Tac-Toe: FAQ

Can the computer be beaten?
Yes. It only looks one move ahead, so it does not see a double threat coming. Open in a corner, take the opposite corner next, then take whichever corner is still free. You now threaten two lines and it can block only one.
Who moves first?
X always moves first. Against the computer you are X and the computer is O. With two players, decide between you who takes X.
Can I play with the keyboard?
Yes. Press Tab until a square has focus, move between squares with the arrow keys, and press Enter or Space to place your mark. The line under the board says whose turn it is and where the computer played.
Is the score saved?
No. The score is kept only while the page is open. It is cleared when you reload the page, press Reset scores or change the opponent.
Does tic-tac-toe always end in a draw?
It does when neither player makes a mistake. We checked this by searching every possible game: if both sides always choose their best move, the board fills up with no winner.

Sources

  • Wikipedia: Tic-tac-toe — a solved game: best play from both players ends in a draw (checked October 16, 2026)