Tic-Tac-Toe
Controls
- Click a cell to place your X.
- The computer plays O automatically.
- First to three in a row (horizontal, vertical, or diagonal) wins.
Tic-Tac-Toe (called Noughts and Crosses in British English, and Xs and Os in some places) is the 3×3 grid game where two players alternate placing their mark (X or O); first to get three in a row wins. With three-in-a-row grids found on ancient Egyptian roofing tiles and a possible Roman cousin, Tic-Tac-Toe belongs to one of the oldest known families of games. It’s also mathematically solved — with perfect play from both sides, every game ends in a draw.
How to play
- 3×3 grid of 9 cells, all empty.
- X traditionally goes first. On this page you can choose X starts, O starts, or Alternate.
- Players take turns placing their mark in an empty cell.
- First to get 3 of their mark in a row (horizontal, vertical, or diagonal) wins.
- If all 9 cells fill without a winner, it’s a draw (Cat’s Game).
- On this page: you play X against the CPU on Impossible (perfect minimax play, never loses), Hard (mostly perfect, with the odd random move) or Easy (random moves), or pick 2 Players to share one device. Keys 1-9 place a mark in reading order (1 = top-left), N starts a new round, and the scoreboard tracks X wins, O wins and draws.
The math: it’s solved
Tic-Tac-Toe has been completely analyzed. There are 255,168 possible games when leaf-counting, or 26,830 once rotations and reflections are treated as the same game. With perfect play from both sides:
- The first player (X) plays optimal.
- The second player (O) plays optimal.
- The game is a forced DRAW.
- If either player blunders, the other can force a win.
- This makes Tic-Tac-Toe a perfect tutorial for game theory and minimax algorithms.
Beginner strategy
- Always play centre first. The centre cell is in 4 winning lines (1 row, 1 column, 2 diagonals). Maximum value.
- Play corners next. Corners are in 3 winning lines (1 row, 1 column, 1 diagonal).
- Avoid edges. Edge cells are in only 2 winning lines.
- Block opponent threats. If the opponent has 2 in a row, block on the 3rd cell.
- Create double threats. Place a mark that creates 2 simultaneous winning lines. The opponent can only block 1.
Intermediate strategy: the fork
The key tactic in Tic-Tac-Toe is the FORK — creating two simultaneous winning lines, so the opponent can only block one. Classic fork setups:
- The “L” fork: X in centre, X in two adjacent corners. Threatens two winning rows simultaneously.
- The corner fork: X in three corners. The two lines between them can’t both be blocked.
- The “double-corner” trap: X in opposite corners with O in the centre. O must answer on an edge; taking a corner lets X fork.
- Preventing forks. When opponent has 2 corners, play centre or edges to block fork formation.
- Creating forks. Most aggressive opens lead to fork setups by move 3-4.
Advanced strategy: perfect play
- X plays centre. O must play corner to prevent eventual fork. An edge reply loses.
- X plays opposite corner. O must take another corner. Blocking at an edge here lets X force a fork and win.
- X blocks, O blocks. From there, each side answers every threat.
- The result: with correct defence from O, the board fills and the game is drawn.
- Perfect play from O = draw. Imperfect play = X wins. Imperfect X play = O can sometimes win.
Why Tic-Tac-Toe is a classic teaching example
- Tree size: 255,168 total game leaves. Small enough to enumerate exhaustively.
- Minimax algorithm: standard intro example for game-theory AI. A 30-line minimax solver plays perfect Tic-Tac-Toe.
- Symmetry reduction: there are 5,478 legal positions, and 8-fold board symmetry cuts them to 765 essentially different ones. Useful for learning game analysis.
- Hash tables and memoization: Tic-Tac-Toe is the canonical example for caching game positions.
Tic-Tac-Toe history
- Egypt, around 1300 BC: three-in-a-row game grids appear on roofing tiles.
- Roman Empire — Terni Lapilli: a 3-in-a-row game in which each player had only three pieces and moved them around. A possible ancestor.
- Modern English name: “Tic Tac Toe” appears in print in the late 19th century.
- 1950 — Bertie the Brain: a giant tic-tac-toe machine shown at the Canadian National Exhibition.
- 1952 — OXO computer game: Alexander Douglas’s PhD thesis includes OXO, one of the earliest video games. EDSAC computer.
- 1970s — Tinkertoy computer: MIT students built a Tinkertoy mechanical computer that played Tic-Tac-Toe. On display at Computer History Museum.
Variants worth playing
- Ultimate Tic-Tac-Toe. 9 small boards in a 3×3 meta-grid. Where you play sends opponent to a specific mini-board. Much deeper.
- 3D Tic-Tac-Toe. Played on a 4×4×4 cube. Many more winning lines.
- Tic-Tac-Toe Misère. 3-in-a-row LOSES (you want to force opponent into the line).
- Connect Four. 7×6 board, gravity-affected pieces; 4-in-a-row to win.
- Gomoku. 15×15 board; 5-in-a-row to win. Direct large-board generalization.
Common mistakes
- Opening on an edge as X. Centre and corners both give O more ways to go wrong. An edge opening is still a draw with best play, but it makes O’s job easiest.
- Not creating fork threats. Without forks, the game converges to draws.
- Missing opponent forks. Block fork-creating moves preemptively.
- Playing edges when corners available. Corners > edges in nearly every position.
FAQ
- Q: Is Tic-Tac-Toe always a draw? A: With perfect play from both sides, yes. Mistakes give the other player a win.
- Q: Best first move? A: Centre or a corner. Centre maximizes the number of winning lines you participate in; a corner leaves O only one safe reply (the centre).
- Q: Why is the centre so important? A: It’s in 4 of 8 possible winning lines (a row, a column, and both diagonals).
- Q: How many games are possible? A: 255,168 distinct game leaves. With symmetry, 26,830 distinct games.
For deeper Tic-Tac-Toe, try Ultimate Tic-Tac-Toe, Connect Four, Gomoku, or Dots and Boxes.
Guides and tips
- Tic-Tac-Toe Strategy: How to Never LoseA tic tac toe strategy that never loses: the best first moves, how to answer as…
- How to Play Tic-Tac-Toe Perfectly (Never Lose)How to play tic-tac-toe perfectly: the eight-step priority list, the best opening and reply, forks that…
- 12 Games Like Tic-Tac-Toe — Free Strategy Games OnlineFree games like tic-tac-toe you can play in your browser: Connect Four, Gomoku, Ultimate Tic-Tac-Toe, Hex,…





