GetHubApps Logo
GetHubApps
⭕
FunFree · In-Browser

Tic-Tac-Toe

Play tic-tac-toe against a friend or the computer, right in your browser.

Your turn (X)

0

You (X)

0

Draws

0

Computer (O)

Play noughts and crosses against the computer or against someone else on the same screen, with the board tracking wins and draws as you go. Set the computer to play perfectly and it becomes genuinely impossible to beat — which is the interesting fact about this game rather than a limitation of the implementation.

Tic-tac-toe is one of the few games that has been completely solved: every position's outcome under perfect play is known. Two players who both play correctly will draw every single time, forever.

The game in numbers

QuantityValue
Possible sequences of play255,168
Distinct reachable positions5,478
Positions after removing symmetry765
Wins for X under perfect play0
Wins for O under perfect play0
Result under perfect playA draw, always

For comparison, chess has an estimated 10⁴⁴ legal positions and remains unsolved. Tic-tac-toe is small enough to enumerate exhaustively on any computer in a fraction of a second.

Perfect play, in order of priority

  1. If you can win this move, take the win.
  2. Otherwise, if the opponent can win next move, block it.
  3. Otherwise, if you can create a fork — two winning threats at once — do so, since the opponent can only block one.
  4. Otherwise, block the opponent's fork, ideally by making a threat that forces them to respond defensively.
  5. Otherwise take the centre, which is the strongest square and part of four winning lines.
  6. Otherwise take the corner opposite the opponent's, then any empty corner, then any empty side.
  7. Follow this list exactly and you cannot lose. There is no seventh rule, because there is no situation it doesn't cover.

Why children stop playing it

Almost everyone abandons tic-tac-toe around the age of eight, and the reason is precise: they have solved it. Once a player internalises the priority list above, every game draws, and a game that always draws stops being a game. It becomes a ritual with a known ending.

That transition is worth noticing, because it is the same thing that happens to any game whose strategy space is exhausted — the difference between tic-tac-toe and chess is only the size of the tree. It's also why the game endures as a teaching example: it's the smallest interesting instance of the minimax algorithm, the same technique that underlies game-playing programs for far larger games.

Frequently asked questions

Can the computer be beaten?
Not when it plays perfectly. The game is solved, and perfect play guarantees at worst a draw for both sides. The best you can achieve against it is a draw.
Does going first give an advantage?
A practical one, not a theoretical one. X has more chances to set a trap and will beat an imperfect opponent more often, but against perfect play the game is still drawn.
What's the best opening move?
The centre. It belongs to four of the eight winning lines, more than any other square. A corner is second best; a side square is weakest.
How many possible games are there?
255,168 distinct sequences of play, reducing to 5,478 reachable positions, or 765 once rotations and reflections are treated as equivalent.
What is a fork?
A move creating two winning threats simultaneously. The opponent can only block one, so the next move wins. Creating and preventing forks is the whole of the game's strategy.
Why do two good players always draw?
Because the game is solved and the drawn result is forced. Once both players know the correct responses, neither can create an advantage the other can't neutralise.

Related tools