Tic-tac-toe
Two players, nine squares, and three in a row to win. You play against the computer: choose who starts, pick how well it plays, and see whether you can beat it. On Unbeatable it never loses, so a draw is a good result. You can also choose Computer against computer and watch the computer play itself. Click a square to place your mark, and get three in a row before the computer does. Choose who starts and how well the computer plays. Hint shows a good square, and Undo takes back your last move. You can also choose Computer against computer and watch the computer play itself.
How it works
- Click an empty square to place your mark. X always moves first.
- The computer answers at once. Get three in a row across, down, or diagonally before it does.
- Stuck? Hint shows a good square, and Undo takes back your last move. Then save a PNG of the board.
How to play
The board has nine squares. X moves first, then the players take turns, one mark per turn, and a mark never moves. Three of your marks in a row, a column, or a diagonal win. When all nine squares are full and nobody has a line, the game is a draw. First move decides who plays X: you, the computer, or each of you in turn, game by game. The score counts your wins, the draws, and the computer's wins.
Three levels
Easy plays almost at random, although it takes a winning square half of the time. Medium always wins when it can and blocks when you threaten a line, but it does not see a fork coming: two threats at once, of which it can only block one. Unbeatable looks ahead to the end of the game before every move and never loses. When several moves are equally good, it picks one at random, so its games are not all alike.
How Unbeatable thinks
It uses minimax. For every empty square it imagines playing there, then every reply you could make, then every answer of its own, down to the end of each game. A won game scores high, a lost one low, and a draw in between, and a quick win scores higher than a slow one. Both players are assumed to choose the move that is best for them, and the computer plays the move with the best score. There are only 255,168 possible games of tic-tac-toe, so it can look at all of them in a moment.
Computer against computer
Choose Computer against computer under Players to watch the computer play both X and O at the level you pick. Speed sets how quickly it moves, and the score counts X's wins, the draws, and O's wins. Pause halts the game, and Undo steps back a move at a time. On Unbeatable every game is a draw, because that is what best play from both sides always gives.
Frequently asked questions
Can you beat the computer on Unbeatable?
No. Tic-tac-toe is solved: with best play from both sides, every game is a draw. Unbeatable always plays a best move, so the most you can get is a draw. On Medium, try a fork. Choose Computer against computer to see it for yourself: two Unbeatable players draw every game.
What is a fork?
A move that makes two lines of two at once. The other player can block only one of them, so the next move wins. Medium blocks a single threat, but it does not look ahead far enough to stop a fork.
Is it better to go first?
Yes. With good play the first player can never lose, and has more chances to win when the other player makes a mistake. Opening in a corner leaves the other player the most ways to go wrong: only a reply in the center holds the draw.
What do Undo and Hint do?
Undo takes back your last move together with the computer's answer, and Redo plays them again. Hint highlights the square Unbeatable would choose in your place.
Does this upload anything?
No. The game runs in your browser, and the board is drawn on a canvas. Save downloads a PNG. Edit opens that image in the PictorX editor.
Ready to try it?
Open PictorX in your browser — no install, no credit card required to start.
Go to Editor