Tic-Tac-Toe vs AI

Play tic-tac-toe against a computer opponent.

You versus the computer

This lets you play tic-tac-toe against a computer opponent that plays strategically. It is a quick game and a nice demonstration of how a simple game can be played perfectly by a computer.

Play your marks against the computer.

Why the computer is hard to beat

Playing tic-tac-toe against a computer reveals something interesting about the game: because it is small and completely solved, a computer can play it perfectly, considering every possible outcome of every move and always choosing the best one. Against a perfect opponent, the best you can achieve is a draw — you cannot win unless the computer is set to make mistakes, and any error on your part will be punished with a loss. This makes it a genuine and slightly humbling challenge, and a great way to sharpen your own play, since you learn the game's strategy by trying to hold the computer to a draw: take the centre, block threats, and avoid the traps that let the opponent fork you. It is also a neat, tangible demonstration of a computer playing a game optimally, the same principle that, scaled up enormously, lets computers master far more complex games. For a quick game that tests whether you can play tic-tac-toe perfectly yourself, facing a flawless computer opponent is the truest test there is.

Common questions

Can I beat a perfect tic-tac-toe computer?

No — with perfect play the best you can get is a draw, since the game is solved. You can only win if the computer is set to make mistakes.

How do I hold it to a draw?

Take the centre when you can, block the computer's two-in-a-row threats, and avoid leaving yourself open to a fork that threatens two wins at once.

Is anything uploaded?

No. It runs entirely in your browser.

More Games & Misc tools