Tic tac toe rules
Tic tac toe is played on a grid of three by three squares. One player uses X, the other O. The players take turns, and each turn puts one mark in an empty square. The first player to fill a whole row, a whole column or one of the two diagonals with their own mark wins. When all nine squares are full and nobody has a line, the game is a draw.
There is no fixed rule about who starts. A common convention is that X goes first, which is why this page starts with X unless you change it. Since the player who moves first can place five marks and the other only four, it is fair to swap the starting player between games. The Take turns setting does that for you.
Easy, medium and hard
The three levels follow simple rules, so you know what you are playing against.
- Easy picks any free square at random. It is a good level for young children and for learning how lines form.
- Medium first checks whether it can complete a line and does so. If not, it checks whether you are about to complete one and blocks it. Otherwise it plays a random square. It does not see forks, so you can beat it by building two threats at once.
- Hard uses a minimax search. For every free square it plays out every possible rest of the game, assumes that you answer with your best move each time, and keeps only the moves with the best result. When several moves are equally good, it picks one of them at random, so the games do not all look alike. A quick win scores higher than a slow one, so it finishes when it can.
Why perfect play always ends in a draw
Tic tac toe is small enough to check completely. We counted every possible game with a short program that plays out all move orders, with X moving first, and stops each game as soon as someone completes a line or the board is full. These are the computed totals:
| What was counted | Number |
|---|---|
| Possible games (different move orders) | 255,168 |
| Games won by X, the first player | 131,184 |
| Games won by O | 77,904 |
| Games that end in a draw | 46,080 |
| Different final boards | 958 |
| Final boards when rotations and mirror images count as one | 138 |
Of those 138 final boards, 91 are wins for X, 44 are wins for O and 3 are draws. More games are won by X because the first player has an extra mark. Yet when both sides look ahead and never make a losing move, every game ends in a draw. The same program shows that the value of the empty board is a draw for both players, and that no opening square changes that. This is why the hard level cannot be beaten: it never makes a mistake, so the best you can reach is a draw.
Strategy tips
A simple priority list plays well. On every turn, take the first rule that applies:
- Win: complete your own line.
- Block: stop the other player's two in a row.
- Fork: make a move that creates two threats at once, so only one can be blocked.
- Block a fork: stop the other player from setting one up.
- Take the center.
- Take the corner opposite the other player's corner.
- Take any empty corner.
- Take any empty side square.
The most common beginner mistake is the answer to a corner opening. When X starts in a corner, the center is the only reply for O that does not lose. Our engine confirms this: against X in a corner, every square except the center leads to a forced win for X.
A worked example
X starts in the top left corner (row 1, column 1). O answers in the top middle square (row 1, column 2), which looks harmless. X takes the center. Now X threatens the diagonal from top left to bottom right, so O must block in the bottom right corner. X then plays the bottom left corner (row 3, column 1). That one move makes two threats: column 1 needs only row 2, and the diagonal from top right needs only the top right corner. O can block one of them, and X completes the other. Try it on easy or medium as X to see the fork, then try the same line against hard as O to see how the computer avoids it.
How to play tic tac toe online
- 1Choose Against the computer or Two players. Against the computer, pick a level and whether you play X or O.
- 2Pick who makes the first move, or Take turns to swap the starting player after every game.
- 3Tap a square to place your mark, or use the arrow keys and Enter. The status line under the board says whose turn it is.
- 4When a line is complete, the three squares are highlighted and the score updates. Press New game for the next round.
Related guides
- Dice and Coin Probability: Odds for 2d6, Doubles and Streaks
- How to Pick a Random Winner Fairly: Draws People Trust
- How to Make a Round Robin Schedule: Pairings and Timing
Frequently asked questions
Can I beat the computer on hard?
No. On hard the computer searches every possible continuation of the game and only plays moves that do not lose. We tested this by letting a program play every possible sequence of moves against it, as X and as O, with either side starting. The human side never won. The best you can do is a draw, and the computer wins every game where you make a mistake it can use.
What is the difference between easy, medium and hard?
Easy picks a random free square every time. Medium completes a line when it can, blocks your line when you have two in a row, and otherwise plays a random square, so it can still walk into a fork. Hard looks ahead to the end of the game and never makes a losing move.
Who goes first?
You decide. In the First move setting pick yourself, the computer, or Take turns, which swaps the starting player after every game. In two-player mode pick X, O or Take turns. A common convention is that X starts, but there is no fixed rule about it.
How do two players play on one device?
Pick Two players. The players share the screen and take turns tapping a square. The status line under the board always says whose turn it is, and the score counts wins for X, wins for O and draws.
Can I play with a keyboard or a screen reader?
Yes. The board is a set of nine buttons. Press Tab to reach it, move between squares with the arrow keys, and press Enter or Space to place your mark. Each square has a label such as "Row 1, column 2, empty", and the status line announces every move and the result.
Is my score saved?
The score counts the games you play in this tab, separately for games against the computer and for two-player games. It is not stored anywhere, so it starts at zero when you reload the page. Reset score sets it to zero right away.