Single player
Tic tac toe vs computer
Play tic tac toe against the computer, free and in your browser. Three difficulty levels, three genuinely different algorithms — and one of them cannot be beaten.
Last updated
Play against the computer
Medium takes any win it sees and blocks yours.
Your turn (X)
How the computer decides its move
The computer opponent uses a different algorithm at each difficulty. Easy picks a random empty square. Medium takes a winning move if one exists, otherwise blocks yours, otherwise prefers the centre and then a corner. Hard runs a complete minimax search of the game tree and plays perfectly, so the best result available against it is a draw.
Easy — random
Easy lists the empty squares and chooses one at random. It has no lookahead at all: it will walk past its own winning move and let you complete a line it could have blocked. It is the right setting for a young player, or for warming up.
Medium — one move ahead
Medium works down a fixed priority list on every turn. First, can it win immediately? If so it plays that square. If not, can you win next move? If so it takes that square to block. Failing both, it takes the centre if free, then a random free corner, then anything.
That makes Medium tactically sound but strategically blind. It never misses a one-move win or a one-move threat, yet it cannot see a fork forming — a position where you create two threats at once. Set up a fork and Medium will dutifully block one of them while you win with the other.
Hard — perfect play
Hard evaluates every legal continuation to the end of the game before choosing. Each final position scores +10 for a computer win, −10 for a loss and 0 for a draw, adjusted by how many moves it takes — so the computer prefers to win quickly and to lose as slowly as possible. It then picks the move with the best guaranteed outcome.
Because tic tac toe is a solved game, perfect play from both sides always ends in a draw. Hard plays perfectly by construction, so it can never lose. Holding it to a draw is a genuine result, and it means you did not make a single mistake.
| Easy | Medium | Hard | |
|---|---|---|---|
| Takes an available win | Only by luck | Always | Always |
| Blocks your winning move | Only by luck | Always | Always |
| Sees a fork coming | No | No | Yes |
| Moves it looks ahead | None | One | All of them |
| Best result you can get | Win | Win | Draw |
How to beat Medium
Open in a corner rather than the centre. Medium will take the centre in reply. Take a second corner on the same edge as your first, and Medium blocks the line between them. Now take the corner diagonally opposite your first: you have two open lines at once, Medium can only block one, and you win on the following move.
Try the same sequence against Hard and it will pre-empt you — it sees the fork several moves before it exists and takes an edge square that defuses it. That difference is the whole point of the three levels.
The same opponent on your phone
The Android app has the identical three levels, chosen from a control directly above the board so you can change level without leaving the round. It runs completely offline — the opponent is computed on your device, not fetched from a server.
FAQ
Questions about the computer opponent
How the levels differ, and whether Hard can be beaten.
How are the three difficulty levels different?
They are three separate algorithms. Easy picks any free square at random and will miss obvious wins. Medium takes a winning move if one exists, blocks yours if it does not, then prefers the centre and corners. Hard searches the entire game tree and plays perfectly every single move.
Can you beat the Hard AI?
No — the best result available against Hard is a draw. Hard evaluates every possible continuation before each move using a minimax search, so it never makes a mistake. Tic tac toe is a solved game: when both players play perfectly the result is always a draw. Beating Hard is mathematically impossible.
Does Tic Tac Toe have ads?
No. No banner ads, no full-screen ads between rounds, no video ads. Nor are there in-app purchases or a paid tier. The app contains no advertising library and no analytics SDK at all, which is why it needs no network permission to work.