Unbeatable Tic-Tac-Toe

This computer plays every move perfectly. You can’t win, but can you avoid losing?

Why you can’t beat it

The computer on this page uses minimax: before every move it looks at every possible way the rest of the game can go, and picks the move with the best guaranteed result. Tic-tac-toe is small (there are 255,168 possible games), so it can see all of them instantly. With perfect play on both sides, tic-tac-toe always ends in a draw.

How to never lose

  • Going first as X: take a corner. It leaves the most room for your opponent to go wrong.
  • Going second as O: if X takes a corner, you must take the centre. If X takes the centre, take a corner.
  • Always block two-in-a-row before building your own line.
  • Watch for forks: a move that creates two threats at once wins against anyone except a perfect player.

Challenges to try

Get ten draws in a row, or draw while playing O (it’s harder than it sounds). Want to actually win? Lower the level to Medium or Easy on the main tic-tac-toe page, or play a friend in 2-player mode.