Skip to content
← Back

❌⭕ Tic-Tac-Toe

Turn: ❌
Player guide

How to play Tic-Tac-Toe

Tic-Tac-Toe, also called noughts and crosses, is played on a 3×3 grid. Two players take turns placing X and O, and the first to line up three marks in a row, column or diagonal wins.

Rules

X always moves first. Players take turns placing one mark in an empty square. Three of your marks in a horizontal, vertical or diagonal line win the game. If all nine squares fill without a line, the game is a draw. Choose 2 Players to play a friend on the same device, or vs AI to play X against the computer.

Controls

  • Click or tap an empty square to place your mark.
  • Mode buttons switch between 2 Players and vs AI.
  • New Game clears the board.

Winning strategy

  • Take the centre on your first move; it is part of four winning lines, more than any other square.
  • If the centre is taken, take a corner rather than an edge.
  • Look for forks: a move that creates two threats at once, because your opponent can block only one.
  • Always block your opponent's two-in-a-row before building your own line.
  • Against the AI, play for a draw: it searches every possible game and never makes a mistake.

History

Three-in-a-row games are very old, and the British name noughts and crosses has been in use since the 19th century. In 1952, OXO on the EDSAC computer at Cambridge became one of the first video games ever made.

FAQ

  • Can you beat the AI? No. It uses the minimax algorithm and plays perfectly, so the best possible result against it is a draw.
  • Is Tic-Tac-Toe always a draw? With perfect play from both sides, yes. Wins happen when one player misses a block or walks into a fork.
  • Can two people play on one device? Yes. Choose 2 Players and take turns tapping the board.

Build it yourself

Curious how this game works? Our step-by-step tutorial Tic-Tac-Toe in JavaScript with Unbeatable Minimax AI rebuilds it from this page's code, with examples you can copy.

Classic X and O game for two players or against the computer AI. Place your marks to get three in a row horizontally, vertically or diagonally. Simple strategy game for all ages.