Skip to content
CornerTools

Tic Tac Toe

Play tic tac toe against an unbeatable computer or a friend, with a best-move view that shows why.

Opponent
Computer level

Your turn (X)

Your record against Medium

Won
0
Drawn
0
Lost
0
Unbeaten run
0

Play tic tac toe, also called noughts and crosses, against the computer at three levels or against a friend on the same device. Switch on Best moves and every empty square shows how the game ends from there if both sides play perfectly, so you can see why a move wins, holds the draw or loses.

The game runs in your browser. Your record against each level, the two-player score and a game in progress stay on this device, so a reload picks up where you left off.

How to use it

Against the computer you play X and it plays O. You start by default; switch on Computer starts to let it move first. With Two players, X and O take turns on one screen, and the player who starts swaps every game.

  • Easy takes a win when it sees one and otherwise plays any free square.
  • Medium takes a win, blocks yours, and otherwise plays the perfect move 60% of the time and a random one the rest. A fork beats it.
  • Impossible plays perfectly and never loses. It takes the fastest win, delays a loss as long as it can, and chooses at random between equally good moves, so games still vary.

Best moves labels each empty square for the player to move: “Win in 3”, “Draw” or “Lose in 2”, counting every move from that one, both players' included. Undo takes back your last move and the computer's reply. A game against the computer that used either is left out of your record, unless you lost it.

A draw is called as soon as neither player can complete a line with the moves left, without filling the board. Against the computer, your record for each level counts wins, draws and losses and your current and best run of games without a loss; a game abandoned for a new one counts as a loss. Two players get a score of wins for X and O and draws, kept until you reset it.

How the Impossible level works

Impossible uses minimax: from the current position it plays out every possible continuation to the end, assumes each side always picks the move best for itself, and scores each square by the result it leads to. Tic tac toe is small enough to search completely. There are 255,168 possible games, but only 5,478 different positions they pass through, and 765 once rotations and reflections are counted as one. Each position is worked out once and remembered.

That search proves the game is a draw with perfect play from both sides: whichever square X opens with, O has a reply that holds the draw, and X can always hold it too. So the best result against Impossible is a draw, and it never loses. Best moves read the same table, so a label always agrees with what Impossible would play.

What the easier levels give up: Easy does not look for your threats, so it blocks one only by chance. Medium blocks a single threat but can miss the move that prevents a fork, two threats at once, and no one can block both.

Worked example: a fork

X opens in a corner and O answers on an edge

After X top left, O top middle, X centre, O bottom right
X O ·
· X ·
· · O
X plays middle left
X O ·
X X ·
· · O

O had to block the diagonal at the bottom right. Now X can fork at the middle left or bottom left: after the middle left, X threatens to win at both the middle right and bottom left, and O can block only one. With Best moves on, the edge reply shows “Lose” from the start; the centre is O's only safe answer to a corner.

Every opening and the replies that hold

For X's first move, O's replies that hold the draw under perfect play; every other reply loses
X opensReplies that loseReplies that hold the draw
Centre4 of 8top left, top right, bottom left and bottom right
Corner (top left)7 of 8centre
Edge (top middle)4 of 8top left, top right, centre and bottom middle

Frequently asked questions

No. Tic tac toe is solved: with perfect play from both sides it is a draw, and Impossible always plays perfectly, so the best you can do is draw. It was checked against every possible sequence of your moves, with you starting and with it starting.
Both draw against perfect play, but a corner leaves the other player the least room: only the centre holds the draw, and every other reply loses. After the centre, any corner reply holds, so a corner gives the other player more ways to go wrong.
Yes. Noughts and crosses is the usual British name, and “X and O” or “XO” are others. The rules are the same: three in a row across, down or diagonally wins.

See also