Skip to main content

Tic-Tac-Toe vs. Unbeatable AI

New

Play tic-tac-toe against a computer opponent that plays perfectly using the minimax algorithm — the best you can achieve is a draw.

tic tac toetic-tac-toe gameminimax algorithmbrowser game
Read the guide
Shortcuts:⌘ KSearch

Your turn (X)

You play X against an unbeatable computer (O) that plays optimally — the best you can do is force a draw.
Continue with:

Frequently Asked Questions

Why is the computer opponent unbeatable?

It uses the minimax algorithm, which exhaustively looks ahead through every possible sequence of remaining moves and always picks the one that guarantees its best possible outcome assuming you also play optimally — since tic-tac-toe is a "solved" game, perfect play from both sides always ends in a draw.

What is the minimax algorithm actually doing?

For every possible move, it recursively simulates the rest of the game assuming both players always pick their best available option, then scores each final outcome (win/loss/draw) and picks the move that leads to the best guaranteed result for the computer — it's the same core concept used in chess engines, just simple enough here to explore the entire game tree.

Is there any way to actually win?

Not against genuinely optimal play — but if you also play perfectly (take the center first, then respond correctly to forks), you can force every game into a draw, which is the best any player can guarantee against a perfect opponent in tic-tac-toe.

Why build an unbeatable AI instead of an easier one?

Tic-tac-toe is simple enough that a less-than-perfect AI would just feel like a bug, since the entire game tree is small enough to search completely — the point of this version is specifically to demonstrate the minimax algorithm doing exactly what it's designed to do.

Related Tools