Tic Tac Toe
Bi-Weekly Leaderboard
Last Season's Winners
The Ultimate Guide to Tic-Tac-Toe (Noughts and Crosses)
Tic-Tac-Toe โ known as Noughts and Crosses in the United Kingdom and Xs and Os in many other countries โ is arguably the most universally recognized game in the world. Its origins stretch back thousands of years: ancient Egyptians played a similar three-in-a-row game on roof tiles around 1300 BCE, and Roman soldiers scratched Terni Lapilli grids into stone throughout the Roman Empire.
While Tic-Tac-Toe is often considered a children's game, it holds an important place in the history of game theory, mathematics, and artificial intelligence. It was one of the first games implemented on a computer โ the 1952 program OXO by Alexander Douglas at the University of Cambridge is among the earliest known video games ever created. Today, Tic-Tac-Toe serves as a foundational teaching tool for combinatorial game theory, minimax algorithms, and AI programming.
How to Play Tic-Tac-Toe โ Complete Rules
Setup
Tic-Tac-Toe is played on a 3ร3 grid (9 squares). Two players take turns: one plays as X and the other as O. The grid starts completely empty.
Gameplay
- X always goes first.
- On each turn, a player places their mark (X or O) in any empty square.
- Once placed, marks cannot be moved or removed.
- Players alternate turns until the game ends.
Winning
The game ends when:
- A player places three of their marks in a row โ horizontally, vertically, or diagonally. That player wins.
- All 9 squares are filled and no player has three in a row. The game is a draw (also called a "cat's game").
Winning Lines
There are exactly 8 possible winning lines on a standard 3ร3 board:
- 3 horizontal rows
- 3 vertical columns
- 2 diagonals
Tic-Tac-Toe Game Specifications
| Detail | Value |
|---|---|
| Board Size | 3 ร 3 (9 squares) |
| Players | 2 |
| Winning Lines | 8 (3 rows + 3 columns + 2 diagonals) |
| Total Possible Games | 255,168 (unique game sequences) |
| Unique Board Positions | 5,478 (accounting for symmetry: 765) |
| Maximum Moves per Game | 9 |
| Skill Type | Pure strategy (no luck/randomness) |
| Solved? | Yes โ perfect play always results in a draw |
Tic-Tac-Toe Strategy โ How to Never Lose
Tic-Tac-Toe is a solved game: with optimal play from both sides, every game ends in a draw. However, most casual players don't play perfectly, which means knowing the right strategy gives you a significant edge. Here's how to play optimally:
1. Take the Center First (If You're X)
The center square is the strongest opening move โ it participates in 4 of the 8 winning lines (both diagonals, the middle row, and the middle column). Starting in the center maximizes your options and puts pressure on your opponent immediately.
2. If Opponent Takes Center, Take a Corner
When playing as O and your opponent opens in the center, your best response is to play in a corner. Corners participate in 3 winning lines each. Playing an edge (side) square is weaker โ it only connects to 2 winning lines โ and can lead to a loss if you don't play perfectly afterward.
3. If Opponent Opens in a Corner, Take the Center
If X opens with a corner move, O must take the center to guarantee a draw. Any other response can lead to a forced loss for O.
4. Create a Fork (Double Threat)
A fork is a position where you have two ways to win on your next move. Since your opponent can only block one, you'll win. Setting up a fork is the primary winning tactic in Tic-Tac-Toe. Example: if you have marks on two corners of the same row with the center between them free, and also a mark that threatens a diagonal โ your opponent can't block both.
5. Block Your Opponent's Fork
If your opponent is setting up a fork, you must either:
- Block the forking square directly, or
- Force a threat (create two-in-a-row) that makes them defend instead of completing their fork โ but only if your forcing move doesn't accidentally let them complete a different fork.
6. Priority Order for Each Move
On every turn, evaluate in this order:
- Win: If you can complete three in a row, do it.
- Block: If your opponent has two in a row, block them.
- Fork: Create a position with two ways to win.
- Block fork: Prevent your opponent from creating a fork.
- Center: Take the center if open.
- Opposite corner: Play a corner opposite your opponent's corner.
- Any corner: Take any open corner.
- Any side: Take any open edge square.
Following this priority list perfectly guarantees you will never lose.
The Mathematics of Tic-Tac-Toe
Despite its simplicity, Tic-Tac-Toe is a rich subject in combinatorial mathematics:
- There are 9! = 362,880 possible orderings of moves, but only 255,168 distinct valid games (since many end before all 9 squares are filled).
- The game tree has 5,478 unique board states โ reduced to 765 when accounting for rotational and reflective symmetry.
- Of all possible completed games, approximately 58% are won by X, 29% are won by O, and 13% are draws โ but this assumes random play. With optimal play, 100% are draws.
- Tic-Tac-Toe is a first-player determined game โ in the absence of restrictions, X has a small advantage but cannot force a win against perfect defense.
Tic-Tac-Toe Variants
| Variant | Key Difference |
|---|---|
| Standard 3ร3 | Classic rules โ 3 in a row to win |
| 4ร4 / 5ร5 Tic-Tac-Toe | Larger boards with increased complexity and fewer draws |
| Ultimate Tic-Tac-Toe | A 3ร3 grid of 3ร3 boards; your move determines which board your opponent plays next |
| Misรจre Tic-Tac-Toe | "Reverse" rules โ the player who gets 3 in a row loses |
| 3D Tic-Tac-Toe | Played on a 4ร4ร4 cube; 76 possible winning lines |
| Gomoku (Five in a Row) | Same concept but on a 15ร15 board with 5 in a row to win |
Glossary of Tic-Tac-Toe Terms
- X โ The first player's mark; always moves first.
- O โ The second player's mark.
- Cat's Game โ A draw; occurs when all 9 squares are filled with no winner.
- Fork โ A position where a player threatens to win in two different ways simultaneously.
- Winning Line โ Any row, column, or diagonal of three matching marks.
- Center โ The middle square of the 3ร3 board; the strongest position (4 winning lines pass through it).
- Corner โ Any of the four corner squares; each connects to 3 winning lines.
- Edge (Side) โ The four non-corner, non-center squares; each connects to only 2 winning lines.
- Minimax โ An algorithm that plays Tic-Tac-Toe perfectly by evaluating all possible future game states.
- Noughts and Crosses โ The British name for Tic-Tac-Toe (O = nought, X = cross).
- Terni Lapilli โ The ancient Roman version of the game, played with 3 stones each that were moved rather than placed.
Tic-Tac-Toe in Computer Science & AI
Tic-Tac-Toe holds a special place in the history of computer science and artificial intelligence:
- 1952 โ OXO: Alexander Douglas created the first known graphical computer game, OXO (a Tic-Tac-Toe program), as part of his PhD thesis at the University of Cambridge.
- 1975 โ Minimax: Tic-Tac-Toe became the canonical teaching example for the minimax algorithm, a decision-making method used in game AI that evaluates all possible game states to find the optimal move.
- 1983 โ WarGames: The film WarGames featured a computer (WOPR) learning the futility of nuclear war by playing Tic-Tac-Toe against itself, concluding that "the only winning move is not to play."
- Modern Teaching: Today, Tic-Tac-Toe remains the first game most students implement when learning game trees, alpha-beta pruning, reinforcement learning, and neural networks.
Frequently Asked Questions About Tic-Tac-Toe
Is Tic-Tac-Toe a solved game?
Yes. Tic-Tac-Toe is a completely solved game. When both players play optimally, every game ends in a draw. X (the first player) has a slight structural advantage but cannot force a win against a perfect opponent. The optimal strategy for all 5,478 possible positions is fully known.
Does X or O go first?
X always goes first in standard Tic-Tac-Toe. This is a universal convention. The first-move advantage is real but modest โ it's enough to prevent O from winning with perfect play, but not enough for X to force a win.
What is the best first move in Tic-Tac-Toe?
The center square is the strongest opening move. It connects to 4 of the 8 winning lines and gives you the most flexibility for creating forks. A corner is the second-best opening. An edge (side) square is the weakest opening โ it connects to only 2 winning lines and gives your opponent the most chances to gain an advantage.
What is a cat's game?
A "cat's game" is the informal term for a draw in Tic-Tac-Toe โ when all 9 squares are filled and neither player has three in a row. The term likely comes from the idea that "the cat got the game" (nobody won). Between skilled players, almost every game ends in a cat's game.
How many possible games of Tic-Tac-Toe are there?
There are 255,168 distinct possible games of Tic-Tac-Toe (counting all different move sequences that lead to different game outcomes). When accounting for rotational and reflective symmetry, there are 26,830 essentially unique games. The number of unique board positions is 5,478 (or 765 with symmetry reduction).
What is a fork in Tic-Tac-Toe?
A fork is a position where you threaten to complete three in a row in two different directions at once. Since your opponent can only block one threat per turn, a fork guarantees a win. Creating forks (and preventing your opponent's forks) is the central strategic skill in Tic-Tac-Toe.
What is Ultimate Tic-Tac-Toe?
Ultimate Tic-Tac-Toe is a popular advanced variant played on a 3ร3 grid of 3ร3 Tic-Tac-Toe boards (81 total squares). The key twist: the position of your move within a small board determines which board your opponent must play in next. This creates deep, chess-like strategy while retaining the familiar Tic-Tac-Toe mechanics. Unlike standard Tic-Tac-Toe, Ultimate Tic-Tac-Toe is not yet solved.
Why is Tic-Tac-Toe important in computer science?
Tic-Tac-Toe is the standard introductory example for teaching game AI algorithms because the game tree is small enough to analyze completely (unlike chess or Go). The minimax algorithm, alpha-beta pruning, reinforcement learning, and Monte Carlo tree search are all commonly taught using Tic-Tac-Toe as the first example. It is also historically significant as the basis for one of the first computer games ever made (OXO, 1952).
What is Noughts and Crosses?
Noughts and Crosses is the British (and Commonwealth) name for Tic-Tac-Toe. "Noughts" refers to the O marks, and "crosses" refers to the X marks. The game is identical โ the only difference is the name. In some countries it's also called "Xs and Os."
Ready to play? Challenge another player to Tic-Tac-Toe online free โ match instantly or invite a friend for a private game!