Play tic tac toe online against the computer or a friend
This tic tac toe game — also called noughts and crosses or X and O — runs right in your browser. Play against the computer at three strengths or hand the device to a friend for a two-player match. Besides the classic 3 × 3 grid you can try a 4 × 4 board and a 5 × 5 board, where you need four in a row instead of three.
The Unbeatable level on 3 × 3 searches the entire game tree, so the best you can do is draw. Easy plays random squares, which is perfect for young children, and Medium takes obvious wins and blocks but makes mistakes the rest of the time. A running tally of wins, losses and draws is kept for each mode.
Nothing is installed and no account is needed; the computer opponent runs locally.
How to use the Tic Tac Toe
- Pick vs computer or Two players, then choose a board: 3 × 3 (three in a row), 4 × 4 or 5 × 5 (four in a row).
- Against the computer, choose a level: Easy (random), Medium or Unbeatable.
- Click or tap an empty square to place your mark. X always moves first. Against the computer you are X in the first round and O in the next, so you take turns going first.
- On a keyboard, move between squares with the arrow keys and press Enter or Space to place a mark. On 3 × 3, the keys 1 to 9 place a mark directly (1 is top-left, 9 is bottom-right).
- When someone completes a line, it is highlighted and the score tally updates. Press New round to play again or Reset scores to start the tally from zero.
Tic Tac Toe features
A perfect opponent
On 3 × 3 the Unbeatable level evaluates every reachable position (fewer than 6,000) with minimax, preferring faster wins and slower losses, so it never loses.
Three difficulty levels
Easy is purely random, Medium wins and blocks when it sees one-move threats, and Unbeatable plays perfectly on 3 × 3 and searches several moves ahead on bigger boards.
Bigger boards
4 × 4 and 5 × 5 boards need four in a row, which makes games longer and opens up forks you cannot build on the small grid.
Two-player mode
Pass the device back and forth; the tally counts X wins, O wins and draws separately from your games against the computer.
Animated marks and winning line
Each X and O is drawn stroke by stroke and the winning line sweeps across the board. With reduced motion turned on in your system, marks appear instantly.
Keyboard and screen readers
Every square is a real button with a label such as “Row 2, column 3, empty”, and the turn and result are announced as they change.
How to never lose at tic tac toe
Tic tac toe is a solved game: with perfect play from both sides it always ends in a draw. Three habits are enough to reach that result against anyone, including the Unbeatable level here.
- Win if you can: look for a line where you already have two marks and the third square is empty.
- Otherwise block: if your opponent has two in a line with the third empty, take that square.
- Create a fork when possible (two lines that each need one more mark) and stop your opponent forking you, usually by forcing them to respond to a threat of your own.
- With no threats on the board, the centre is the strongest square, then the corners, then the edges.
- Going second, answer a corner opening with the centre and an opening in the centre with a corner. Taking an edge in reply to a corner is the classic losing mistake.
How the computer chooses its moves
On the 3 × 3 board the Unbeatable level uses the minimax algorithm: it plays out every possible continuation to the end of the game, scores wins as positive and losses as negative, and assumes you will always choose the reply that is worst for it. When several moves are equally good, it picks one at random, so games vary.
The 4 × 4 and 5 × 5 boards have far too many positions to search completely in a browser, so the computer uses depth-limited alpha-beta search for about a third of a second per move. Positions it cannot search to the end are scored by counting lines that are still open for each side — a line holding three of your marks and none of its own counts far more than a line with one. It always takes a winning square and blocks yours first. That makes it very hard to beat on big boards, but not mathematically perfect.
Board sizes compared
- For more quick browser games, try minesweeper, the 2048 game or a round of rock paper scissors; if you enjoy thinking ahead, play chess against the computer.
| Board | Line to win | Result with perfect play |
|---|---|---|
| 3 × 3 | 3 in a row | Draw |
| 4 × 4 | 4 in a row | Draw |
| 5 × 5 | 4 in a row | Not commonly published; room for forks and traps |
Tic Tac Toe FAQ
Can you beat the unbeatable tic tac toe computer?
Not on the 3 × 3 board. It searches every possible game, so perfect play from you ends in a draw and any mistake lets it win. On 4 × 4 and 5 × 5 it searches a few moves ahead, so a deep trap can occasionally beat it.
Who goes first in tic tac toe?
X always moves first. Against the computer you play X in the first round and O in the second, so the first move alternates between you and the computer.
Is tic tac toe always a draw?
Between two perfect players, yes — both on 3 × 3 with three in a row and on 4 × 4 with four in a row. Real games are decided by someone missing a block or walking into a fork.
Can two people play on the same device?
Yes. Choose Two players and take turns tapping squares. The tally counts X wins, O wins and draws.
Does it work on a phone?
Yes. The board scales to the screen and each square is a large tap target.
What is the difference between noughts and crosses and tic tac toe?
Nothing but the name: noughts and crosses is the usual name in the UK, Ireland, Australia and India, while tic tac toe is common in the US and Canada.