Games · Free tool
Tic Tac Toe
Play tic-tac-toe online vs unbeatable AI or a friend. Tracks wins, losses, draws. Free.
X to move
X wins
0
O wins
0
Draws
0
AI uses minimax with full game-tree search — 9-cell board is small enough that it’s instant. Best you can do is draw.
Advertisement
What it does
The classic 3×3 tic-tac-toe game with an unbeatable AI opponent powered by full minimax search. Three modes: vs Easy AI (random moves — beatable most of the time), vs Hard AI (perfect minimax — best you can do is force a draw), vs Friend (pass-and-play, two players on one device). Win/loss/draw stats track across your session.
Tic-tac-toe is the canonical example of a solved game — one where perfect play from both sides always leads to a draw. The mathematical analysis dates to at least the 1960s; with optimal play, neither player can force a win. The minimax algorithm (introduced in 1928 by John von Neumann) is the theoretical foundation for solving any zero-sum game, including chess and Go (though those games are too large to be solved exhaustively the way tic-tac-toe is).
The AI here implements full minimax with alpha-beta pruning over the entire tic-tac-toe game tree — there are only ~26,830 distinct positions, so the algorithm runs in microseconds. It evaluates every possible continuation from each move and picks the one that maximizes your worst-case outcome. There's no random variation, no opening book hacks; it's just pure search. Try to win for a while, then enjoy figuring out the drawing strategy.
Embed this tool on your siteShow snippetHide
Paste this snippet into any page. Loads on-demand (lazy), no tracking scripts, and sized to most dashboards. Replace the height to fit your layout.
<iframe src="https://freetoolarena.com/embed/tic-tac-toe" width="100%" height="720" frameborder="0" loading="lazy" title="Tic Tac Toe" style="border:1px solid #e2e8f0;border-radius:12px;max-width:720px;"></iframe>How to use it
- Pick the mode: Easy AI (random play, you'll usually win), Hard AI (minimax, you can only draw), or Friend (pass-and-play).
- Click any empty square to place your X. The first move is yours by convention.
- Watch the AI (or your friend) play O.
- Three in a row — horizontally, vertically, or diagonally — wins.
- After the game ends, click 'New game' to start over. Stats track across your session.
When to use this tool
- Quick 30-second break — most games end in 5-9 moves.
- Teaching kids the minimax concept (start them on Easy, then explain why Hard is unbeatable).
- Demonstrating game-theory ideas in CS lectures or educational content.
- Casual two-player game when you're sharing a single screen / phone.
When not to use it
- When you want a long game — tic-tac-toe is intentionally short.
- When you want strategic depth — connect-four, chess, Go all offer more depth. Tic-tac-toe is solved.
- Multiplayer over the network — this is local-only (you and the AI, or pass-and-play).
Common use cases
- Onboarding a colleague who needs the same calculation/conversion
- Verifying a number or output before passing it on
- Quick use during a typical workday
- Pre-decision sanity-check on inputs and outputs
Frequently asked questions
- Can I beat the Hard AI?
- No. With perfect play, tic-tac-toe is always a draw — neither side can force a win. The minimax AI here never makes a suboptimal move; the best outcome you can achieve is a draw. If you do better than that, there's a bug in the AI (please report).
- What's the optimal first move?
- Center is universally best — it's part of 4 of the 8 possible winning lines. Corners are second-best (each is part of 3 winning lines). Edges are worst (part of only 2 winning lines). Against a perfect AI, the strongest opening play is center; against a weaker AI, corner traps work well.
- How does minimax work?
- From the current position, recursively evaluate every possible move. For each, recursively evaluate the opponent's best response, and so on, all the way down. Score leaf positions: +1 for AI win, -1 for AI loss, 0 for draw. Each level alternates between picking the maximum (AI's turn) and minimum (opponent's turn) of children. The AI plays the move leading to the best worst-case outcome.
- Why does the Easy AI sometimes still win?
- Because you're playing first (X), and even random opponents occasionally get lucky if you make a mistake. The 'Easy' AI doesn't see threats; if you set up a fork (two simultaneous winning lines), it'll let you win. But if you don't see the same forks the AI doesn't see, you'll occasionally lose to a random move that happens to be a winning move.
- Is the game tree really only 26,830 positions?
- Yes — that's the count of distinct legal positions accounting for symmetries. Naive count is 9! = 362,880, but most of those are equivalent under rotation/reflection or end games early. Either way, the game tree is small enough to fully solve in a few microseconds on any modern computer.
- Are there variants?
- Yes — gomoku (5-in-a-row on a larger board), 4×4 tic-tac-toe (also a draw with perfect play), 3D tic-tac-toe, ultimate tic-tac-toe (a meta-board where moves on the small grid send opponent to the corresponding small grid). These are all interesting; full minimax doesn't work on the larger ones because the game tree explodes.
Advertisement
Explore more games tools
- PongClassic Pong. Mouse or finger controls your paddle. Ball speeds up with each rally.
- MinesweeperClassic Minesweeper on a 9x9 grid with 10 mines. Left-click to reveal, right-click to flag.
- Wordle CloneWordle-style 5-letter word guessing. 6 attempts. Green / yellow / gray feedback.
- Tower of HanoiMove all disks to the right peg. Larger disks can't go on smaller. Optimal solves in 2^n minus 1 moves.
- 15 PuzzleClassic 15-puzzle slider. Arrange tiles 1-15 in order. Every shuffle is solvable.
- Simon SaysMemorize and repeat color sequences. Each round adds one color. Best round saves.