Tic-Tac-Toe

You can rate the game:
(0)

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 references in Roman archaeology and ancient Egyptian tablets, Tic-Tac-Toe is one of the oldest known 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 goes first.
  • 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).

The math: it’s solved

Tic-Tac-Toe has been completely analyzed. The game has 255,168 possible games when leaf-counting; 26,830 unique positions accounting for symmetry. 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 “T” fork: X in centre, X in opposite edge, X in two opposite corners.
  • The “double-corner” fork: X in opposite corners. Forces opponent to play on the edge between them.
  • 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.
  • X plays opposite corner. O blocks at edge.
  • X plays edge to create fork threat. O blocks.
  • X completes fork. O can only block one threat. X wins.
  • But: O can play strictly defensive corners and edges to force a draw.
  • 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: 8-fold board symmetry reduces unique positions from 26,830 to ~5,478. Useful for learning game analysis.
  • Hash tables and memoization: Tic-Tac-Toe is the canonical example for caching game positions.

Tic-Tac-Toe history

  • Roman Empire — Terni Lapilli: a 3-in-a-row game played on tablets. Direct ancestor.
  • Egyptian dynasties: 3×3 board games appear in archaeological evidence from 1300 BC.
  • Modern English name: “Tic Tac Toe” appears in print in the late 19th century.
  • 1952 — OXO computer game: Alexander Douglas’s PhD thesis includes OXO, the first computer Tic-Tac-Toe. EDSAC computer.
  • 1976 — 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

  • Not playing centre as X first. Centre is optimal. Any other opening gives O equal chances.
  • 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. Maximizes the number of winning lines you participate in.
  • 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 unique positions.

For deeper Tic-Tac-Toe, try Ultimate Tic-Tac-Toe, Connect Four, Gomoku, or Dots and Boxes.

🔌 Connect any AI assistant to dinogame.gg — we run an MCP server: https://dinogame.gg/wp-json/dinogame/v1/mcp