Play free Tic Tac Toe against a computer at three levels, including one that never loses, or against a friend on the same device.
Turn Your turn (X)
You (X)0
Draws0
Computer (O)0
Unbeaten streak (Medium): 0 - best saved: -
Arrow keys move between squares, Enter or Space places your mark, and the number keys 1 to 9 place one directly (1 is top left, 9 is bottom right). The tally counts finished games (against the computer, or X and O wins in two-player mode); the unbeaten streak counts only finished games against the computer, where a win or a draw extends it and a loss ends it. Restarting a game you have already moved in also ends the streak. Difficulty and "You play" apply to the computer only.
Easy picks any empty square at random. Medium takes a winning square if it has one, otherwise blocks yours, otherwise picks at random. Unbeatable uses minimax: it imagines every possible continuation, assumes you will always reply as well as you can, and plays the square whose worst case is best. Only 5,478 different positions can ever occur, so it simply solves all of them, and it never loses as X or as O. Against perfect play every game is a draw.
As-is, no warranty. These apps are free under their listed license and run entirely in your browser. Use at your own risk — don't blame me if your PC catches fire, your dog runs away, or the math turns out wrong. Verify anything that actually matters. None of this is professional financial, medical, legal, or engineering advice.
Take turns placing X and O on a 3 x 3 grid. The first to get three in a row, across, down or diagonally, wins. If the board fills up with no line, it is a draw. X always goes first.
Pick Computer or Two players on this device under Opponent. Against the computer, choose a difficulty and whether you play X (you move first) or O (the computer moves first). Click or tap a square, or use the keyboard: arrow keys move between squares, Enter or Space places your mark, and the number keys 1 to 9 place one directly (1 is the top left, 9 is the bottom right). X is drawn in sky blue and O in rose, inside a violet frame, and the Turn pill and the tally boxes use the same two colours (amber for draws). On a device with a mouse, hovering an empty square shows a faint preview of the mark you are about to place. The winning line sweeps in green, and it is also outlined, filled and underlined, so it does not rely on colour alone.
The computer answers after a short pause of about a third of a second, and the board is locked while it thinks. If your system asks for reduced motion, the pause, the pop-in animation, the winning sweep and the small dots that appear after a win are all switched off.
The board has only nine squares, so it can be searched completely. Counting by exhaustive enumeration, which the test suite repeats on every run:
The three difficulties use that structure in different amounts:
What the tests prove about Unbeatable: they walk every possible sequence of opponent moves, with Unbeatable playing any of its best moves at each turn, once with it as X and once with it as O. It does not lose in a single one. Two Unbeatable players always draw, which matches the long-known result that Tic Tac Toe is a draw under perfect play. The tests also check the minimax values against a plain, separate depth-first search of every position, and check that Medium takes an immediate win and an immediate block in every position where one exists.
Nothing is uploaded and there is no account. Your session tally (wins, draws, losses, or X wins, draws and O wins in two-player mode) lives only in the open page and disappears when you leave it. The only thing saved is your best unbeaten streak per difficulty, as small whole numbers inside a small JSON object in your browser’s local storage under one key. Clearing site data removes it. The page address records your settings (opponent, difficulty, side) so you can bookmark them, and nothing else.
Everything runs locally in your browser.
For informational purposes only. Not financial, medical, or legal advice. You are solely responsible for how you use these tools.