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:
- If it has two in a line and the third square is empty, it takes that square and wins.
- If you have two in a line and the third square is empty, it blocks you.
- If the center is empty, it takes the center.
- If a corner is empty, it takes one of the empty corners at random.
- 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:
- Take a corner. The computer takes the center (rule 3).
- Take the opposite corner. Nothing needs blocking, so the computer takes one of the two free corners (rule 4).
- It now has two on a diagonal. Take the last free corner, which blocks that diagonal.
- You now have three corners and two open lines along the edges. The computer can block only one (rule 2).
- 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.
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?
Who moves first?
Can I play with the keyboard?
Is the score saved?
Does tic-tac-toe always end in a draw?
Sources
- Wikipedia: Tic-tac-toe — a solved game: best play from both players ends in a draw (checked October 16, 2026)