Tic-Tac-Toe

Tic-tac-toe in the browser, on a phone, a tablet or a computer. Play against the computer at three levels, or pass the device to a friend. The top level, PERFECT, has solved the game and cannot be beaten.

How to play

Tap a square. Three in a row wins — across, down or corner to corner. You are always X, and the first move changes hands every game, because going first matters.

PERFECT has solved the game and cannot be beaten. That is not a boast, it is what noughts and crosses is: two people who never err always draw. Holding it to a draw over and over is the whole score, which is why the record kept is your longest run without losing.

Beat SLOPPY and SHARP instead — they make real mistakes, and SLOPPY makes plenty.

How the unbeatable opponent works

Tic-tac-toe is small enough to solve outright. Before every move, PERFECT follows every way the rest of the game could go and keeps only the moves that lead to the best result it can force. That takes under a millisecond.

When several moves are equally good it picks one at random, so a solved opponent still plays a different game each time instead of the same script.

The claim is tested, not hoped for. A check plays every game a person could try against it, with either side moving first and down every move it rates equal-best, and none of them ends in a win for the person.

The opponents

All three levels use the same solver. Difficulty is one dial: how often it throws the answer away and plays a random square.

SLOPPY does that about two moves in three and is beatable by anyone. SHARP does it about one move in five, so it blocks you most of the time and slips now and then. PERFECT never does.

Even a careless move usually takes a win it can see on the board, because missing an open three-in-a-row reads as broken rather than easy. PASS & PLAY skips the computer: two people, one screen, taking turns opening.

Records

Records stay in your browser, kept per opponent: wins, losses, draws, and your longest run of games without a loss.

Against PERFECT a win is impossible, so that run is the only score that means anything. It happens to be the right score against the other two as well.

There is no end screen. A game lasts about thirty seconds, so the result shows under the board, the winning line is struck through, and the running score stays in view.

More games