Tic-Tac-Toe
The paper-and-pencil classic, rebuilt for the browser. You play X against the computer's O on a 3×3 grid — pick your difficulty, line up three in a row, and try to outsmart an AI that, on its hardest setting, simply cannot lose.
▶ Play Tic-Tac-Toe
What is Tic-Tac-Toe?
Tic-tac-toe is the two-player pencil game almost everyone learns as a kid: a 3×3 grid, one player marking X's and the other marking O's, taking turns until someone gets three of their own marks in a straight line. This version puts you against the computer. You are always X and you always move first — a small but real advantage — and the computer answers as O after a short pause of about a third of a second, so it feels like a real opponent taking its turn rather than snapping back instantly.
A line can run three ways: across a row, straight down a column, or corner-to-corner along either diagonal. That is eight winning lines in total, and the game checks all eight after every single mark. The moment three matching marks complete any of them, that line lights up gold and the round ends. If all nine squares fill without a line, the game is a draw — and as you'll see below, against perfect play a draw is the honest outcome.
How to play
- Pick a difficulty. Three buttons sit above the board — Easy, Medium and Hard. Medium is selected by default. You can switch at any time; the choice takes effect on the computer's next move, so you don't have to restart the round to change opponents.
- Make the first move. You're X, and X always goes first. Tap or click any empty square to drop your mark. Squares that are already taken won't respond.
- Let the computer reply. After you move, the status line reads “CPU is thinking…” and O appears in one of the empty squares about 300 milliseconds later. Then it's your turn again.
- Build toward three in a row. Keep placing X's to complete any row, column or diagonal — while watching that the computer isn't one move away from completing a line of its own.
- Win, lose or draw. When a line is finished the three winning squares are highlighted and an overlay tells you the result. If every square fills with no line, it's a draw.
- Play again. Hit “Play Again” on the overlay to clear the board and start a fresh round with the same difficulty. Your running record carries over.
The three difficulty levels
Each level is a genuinely different opponent, not just a speed change:
- Easy plays almost entirely at random. It only rarely — roughly one move in seven — bothers to take a winning move that's sitting right in front of it, and it never plays defence. This is the level to beat comfortably or to hand to a younger player.
- Medium plays the obvious tactics. If it can win this turn, it takes the win; if you're one move from three in a row, it blocks you; otherwise it moves at random. It won't set traps of its own, but it won't hand you an easy victory either.
- Hard is perfect. It searches every possible continuation of the game and always picks a move that leads to the best guaranteed outcome for itself. You cannot beat it — the very best result available to you is a draw.
Can you beat the Hard AI?
No — and that isn't a bug, it's the whole point. The Hard opponent runs an algorithm called minimax. Before each move it plays out every legal sequence of moves to the end of the game, scoring a win for itself highly, a loss badly, and a draw as neutral, then it picks the move whose worst-case outcome is best. Because tic-tac-toe is a small, fully solved game, this search is exhaustive: the computer literally sees every future the board can reach and steers away from any line where it could lose.
Tic-tac-toe is what game theorists call a solved game, and its solution is famous: with perfect play from both sides, every game is a draw. So against Hard, a draw is a victory of sorts — it means you played flawlessly too. The Hard AI will punish any mistake instantly, but if you never give it an opening, it can never manufacture one. When more than one move is equally perfect, it picks randomly among them, so it won't play the identical game twice.
To hold the draw against Hard, a few principles genuinely help:
- Open in a corner or the centre. These are the strongest first moves for X. A corner in particular gives you the most ways to threaten a line later.
- Always answer a threat. If the computer has two marks on a line with the third square open, block it that turn — no exceptions.
- Watch for forks, and set your own. A fork is a single move that creates two winning threats at once, so your opponent can only block one. Perfect play is largely about creating forks against a fallible opponent and refusing to walk into theirs. Hard never lets you fork it; on Easy and Medium, a well-placed corner-and-centre combination often can.
Practically, that means Hard is where you go to test whether your own play is airtight, while Easy and Medium are where forks and traps actually earn you wins.
Your record is saved: The game keeps a running tally of games Won, Lost and Drew across the top of the board, and stores those three numbers locally in your browser. Close the tab and come back tomorrow and your record is still there — no login, nothing else about your session is kept. The tally counts every round regardless of difficulty, so a session spent drawing against Hard adds to the Drew column just as your Easy wins add to Won. See our Privacy Policy for details.
Frequently asked questions
Is Hard mode beatable?
No. The Hard AI uses full minimax search, which means it plays perfectly and never makes a mistake. Since tic-tac-toe is a solved game, the best any player can achieve against perfect play is a draw — so drawing Hard is the strongest result possible.
Who goes first?
You do, every round. You are always X, and X always moves first. The computer plays O and responds after your move.
What's the difference between the difficulty levels?
Easy moves almost at random and rarely even takes a free win. Medium takes an obvious win or blocks your obvious threat, otherwise moves at random. Hard searches the whole game tree with minimax and plays perfectly.
Can I change difficulty mid-game?
Yes. Tap a different difficulty button at any time and it applies from the computer's next move onward — you don't need to restart the round.
Is my win/loss record saved?
Yes. Your Won, Lost and Drew totals are stored locally in your browser, so they persist between visits on the same device. No account is needed.
Do I need to install anything?
No. Tic-Tac-Toe runs entirely in your browser on desktop or mobile — no downloads, plugins or sign-ups, and it's completely free.