Tic-Tac-Toe

Get three in a row before your opponent does. Play a friend on the same screen or test yourself against a computer with three difficulty levels, including one that never loses.

How to play Tic-Tac-Toe

Two players take turns placing their mark, X or O, in an empty square of a 3 × 3 grid. The first player to line up three of their marks in a row, column or diagonal wins. If all nine squares fill up with no line of three, the game is a draw. That's the whole rulebook.

On this page, the first move swaps between X and O each round so neither side always has the advantage. The score bar keeps a running tally of wins and draws until you reset it.

Difficulty levels

  • Easy mostly plays random squares. It will sometimes take a win if one is sitting in front of it, but it won't block yours.
  • Medium always takes a winning move and always blocks your immediate threats, but it doesn't plan ahead, so you can beat it with a fork.
  • Unbeatable searches every possible future position (a method called minimax) and picks the best move. The best you can do against it is a draw.

Strategy in brief

Tic-tac-toe is a solved game: if both players make no mistakes, every game ends in a draw. Winning therefore depends on your opponent slipping up, and the way to make that happen is to create a fork, a single move that threatens to complete two different lines at once. Your opponent can only block one of them.

  • Going first? Start in a corner. A corner opening gives your opponent the most ways to go wrong; any reply other than the centre loses against correct play.
  • Going second? If the first move was a corner, take the centre. If it was the centre, take a corner. Answering the centre with an edge square is a well-known losing move.
  • Every turn, check in this order: can I win right now? Must I block? Can I make a fork? Can I stop their fork?

Our full guide, How to never lose at Tic-Tac-Toe, walks through every opening with diagrams.

A very old game

Three-in-a-row games are thousands of years old. Grids for similar games have been found scratched into stone in many parts of the world, and the paper-and-pencil version has been a classroom favourite for generations. It's also a common first project for people learning to program a computer opponent, because the game is small enough for a computer to examine every single possible game, about a quarter of a million of them, in a fraction of a second.

Frequently asked questions

Can you beat the unbeatable computer?

No. It examines every possible continuation and never makes a losing move, so the best result is a draw. Easy and Medium can be beaten.

Who goes first?

The first move alternates each round between X and O, so you get the opening advantage every other game.

Is tic-tac-toe always a draw?

With perfect play from both sides, yes. Wins only happen when one player makes a mistake, which is why forks are so important.