Tic Tac Toe

Take turns marking squares on a three-by-three grid; three of yours in a line wins it. Play the computer at three levels, the hardest of which genuinely cannot be beaten, so the best you will get out of it is a draw.

How to play

You play X, so the first move is yours, and on the easier two settings that head start is enough to win with.

  1. Choose a difficulty Easy plays mostly at random. Normal usually finds the best move. Unbeatable always does, and cannot be beaten by anyone.
  2. Decide who starts Going first is a real advantage in this game, so you can hand it to the computer if you want a harder time.
  3. Click a square Your X appears and the computer replies after a moment.
Full instructions

In depth

Playing noughts and crosses against a computer that never blunders

The complete rules, how the three difficulty levels actually work inside, why going first matters so much, how to create a fork, and what perfect play really means on a board this small.

Screenshot: How to play Tic Tac Toe
How to play Tic Tac Toe as it appears when the page opens.

The rules of the game

Two players take turns marking squares on a three-by-three grid. You play as X and the computer plays as O. The first player to get three of their marks in a straight line wins. That line can go across any row, down any column, or along either diagonal. If all nine squares are filled and nobody has three in a row, the game is a draw.

Only one mark can go in each square, and marks cannot be moved after they are placed. A game lasts at most nine turns, five for whoever goes first and four for whoever goes second.

Controls and the scoreboard

Click or tap any empty square to place your X. The computer replies after a brief pause, placing its O. A message below the board tells you whose turn it is. When the game ends, the winning line is highlighted on the board.

Above the board, a running tally shows how many games you have won, how many ended in a draw, and how many the computer won. This score is kept while the page is open. It is not stored between visits. The New game button starts a fresh round without resetting the tally.

The three difficulty levels

The Computer dropdown offers Easy, Normal and Unbeatable. The difference is not how deeply the computer searches. On a board this small, searching every possible future takes almost no time at all. The difference is how often the computer chooses to use that search.

Easy plays a random move three quarters of the time and only checks the best move one quarter of the time. That makes it beatable by anyone who knows the basics. Normal usually finds the best move but plays randomly about one quarter of the time, leaving occasional openings. Unbeatable always picks the best move and cannot be beaten by anyone. A draw is the best result you can achieve against it.

This design is more honest than some others. Rather than weakening the search to produce a computer that plays well and then blunders for no reason, the easier levels simply admit they are not trying on some turns.

Choosing who goes first

The Goes first dropdown lets you decide whether you or the computer takes the opening move. Going first is a real advantage. The first player has five turns while the second player has only four. More turns mean more chances to build toward a winning line.

When you go first, correct play guarantees at least a draw. When the computer goes first on Unbeatable, correct play still guarantees a draw, but the margin for error is smaller. Giving the computer the first move on Easy or Normal makes the game harder without changing the difficulty level, which is a good middle step when Easy feels too simple but Normal feels too random.

Why the centre square matters so much

The nine squares on the board are not equal. The centre square belongs to four winning lines: the middle row, the middle column, and both diagonals. A corner belongs to three winning lines: its row, its column, and one diagonal. An edge square belongs to only two: its row and its column.

If you go first, take the centre. It gives you the widest spread of threats and makes it much harder for the computer to block everything. If the computer takes the centre on its first move, take a corner. A corner is the second strongest position because it sits on three lines and forces the computer to defend on more fronts than an edge would.

The fork: the only way to win

Against any opponent who blocks obvious threats, the only reliable way to win is to create two threats at the same time. This is called a fork. When you have two lines that each need one more mark to complete, the opponent can block only one of them. The other line completes on your next turn.

The classic fork on this board works like this. You take the centre and two opposite corners. That gives you one threat along the diagonal and another along a row or column. The computer can block one, but not both. Against Easy and Normal, setting up a fork works often because their random turns may miss the chance to prevent it.

Against Unbeatable, the computer never lets you build a fork. Every time you get close, it takes the square that would complete your second threat. That is why draws are the natural outcome of two perfect players.

Defending against forks

The same fork idea works for the computer. If you see the computer placing marks in two intersecting lines, it is setting up a fork of its own. You need to block the intersection square, the one square that belongs to both lines, before the computer plays there.

A common trap is to focus on blocking one visible threat without noticing that the computer now has another threat open. Always scan the whole board before you place. Count how many near-complete lines the computer has and where they overlap. If two of its lines share an empty square, that square is urgent.

A sample game from opening to finish

You go first and take the centre. The computer on Easy plays a random edge, say the top middle. You take a corner, bottom left. Now you have the centre and a corner, sitting on a diagonal. The computer plays another random square, perhaps the right edge. You take the opposite corner, top right. That gives you two threats: one along the diagonal from top right to bottom left, and one along the bottom row if you also hold the centre. The computer can block one but not both.

Notice how the win came from planning two moves ahead. The first corner set up the diagonal. The second corner completed the fork. Against Normal, this same pattern works less often because the computer sometimes blocks the critical corner. Against Unbeatable, it never works at all because the computer takes the blocking corner every time.

Studying a few games like this teaches you to see the fork before you play the first corner, not after.

What happens when both players are perfect

Tic Tac Toe is a solved game. Every position has been mapped and the result is known: with correct play from both sides, every game ends in a draw. That is why Unbeatable cannot be beaten. It follows the known best moves at every point.

This might sound discouraging, but it is actually the point of the Unbeatable level. It exists as proof that the game is exhausted. No sequence of moves, no matter how clever, can force a win against a perfect opponent. Try it, satisfy yourself, and then switch to Normal or Easy if you want games that can go either way.

The computer on Unbeatable also prefers to win sooner rather than later. If two moves both lead to a win, it picks the one that ends the game in fewer turns. That is why it never wanders toward a slow victory when a fast one is available.

Common beginner mistakes

  • Taking an edge square first. Edges sit on only two lines. The centre and corners are always stronger opening moves.
  • Blocking one threat without looking for a second. The computer may already have two threats, and blocking only one means losing on the next turn.
  • Ignoring diagonals. New players often scan rows and columns but forget the two diagonal lines. Check them on every turn.
  • Giving up after a draw. On Unbeatable, a draw is the best possible result. It means you played perfectly.
  • Forgetting to change who goes first. If every game feels the same, switch the Goes first dropdown. Going second changes the opening strategy completely.

The computer runs entirely in your browser

All of the computer's thinking happens on your own device. The minimax search that powers the Unbeatable level examines every possible future of the game and runs in a fraction of a second on any modern browser. Nothing is uploaded to a server, the game works offline after the page loads, and no personal data is collected.

Help

How to play Tic Tac Toe

You play X, so the first move is yours, and on the easier two settings that head start is enough to win with. The hardest opponent never makes a mistake, so a draw there is the right result rather than a disappointing one, and a loss is something you did rather than something it did.

Choose a difficulty

Easy plays mostly at random. Normal usually finds the best move. Unbeatable always does, and cannot be beaten by anyone.

Decide who starts

Going first is a real advantage in this game, so you can hand it to the computer if you want a harder time.

Click a square

Your X appears and the computer replies after a moment.

Get three in a row

Across, down or diagonally. The winning line is highlighted when the game ends.

Play again

Your running score of wins, draws and losses is shown above the board.

Everything runs on your device

The computer's thinking happens in your browser. Nothing is uploaded, and the game works with the internet disconnected.

Good to know

Take the centre

The middle square is part of four possible winning lines — more than any other square. If you go first and take it, you cannot lose with correct play.

Corners beat edges

A corner belongs to three winning lines, an edge to only two. When the centre is gone, take a corner.

Unbeatable really is unbeatable

On the hardest level the computer looks at every possible continuation before moving. A draw is the best result available to you — that is a property of the game, not a limitation of your play.

Look for the fork

The way to actually win is to create two threats at once, so blocking one lets the other through. Against Easy and Normal this works often.

Common questions

Can I beat the Unbeatable level?
No, and that is deliberate. It checks every possible continuation before each move, so it never makes a mistake. A draw is the best result available against it.
Why do I keep drawing?
Tic Tac Toe is a solved game — if both players play correctly, every game is a draw. That is why the easier levels deliberately make mistakes sometimes.
Which square should I open with?
The centre. It belongs to four possible winning lines, more than any other square.
Does going first matter?
Yes, quite a lot. The first player has more chances to create a double threat, which is why you can choose to give the computer the first move.
Is my score saved?
The running total is kept while the page is open. It is not stored between visits.
Is it good for young children?
Yes — set the computer to Easy. There is nothing to buy, no chat and no ads inside the game area.