ctrlcat games Tic-Tac-Toe vs AI
Strategy

Tic-Tac-Toe vs AI

Play tic-tac-toe against an unbeatable AI. Can you force a draw? A perfect game of strategy in under a minute.

Medium ~1 min
Tic-Tac-Toe
Choose your settings before starting
Difficulty
You play as

A game with a solved ending

Tic-tac-toe traces back thousands of years — variations of the game appeared in ancient Egypt and Rome. The rules are about as simple as a game can be: two players take turns placing their mark on a 3×3 grid, and the first to align three in a row wins. Despite that simplicity, the game is fully solved: if both players play perfectly, the result is always a draw.

Why the AI never loses

This AI uses an algorithm called minimax. Before each move, it simulates every possible sequence of moves until the game ends, calculates the outcome, and picks the move that leads to the best result — assuming you also play your best.

Tic-tac-toe has few enough possible game states that the AI can consider all of them in a fraction of a second. It makes no mistakes. You cannot win; a draw is the best outcome you can achieve.

How to draw against a perfect opponent

Start in a corner. Corner openings give you more future options than edge or center starts and make it harder for the AI to close off your winning paths. Center is also a strong first move.

Once the game is in progress, two rules cover most situations: if you can complete a line of three, do it; if the AI is one move from completing a line, block it. Keeping both in mind simultaneously is the key challenge.

In some positions you can create a fork — a situation where you threaten to win in two different places at once. The AI can only block one, so the other wins. The AI also calculates these positions in advance and avoids letting them happen.

Score

Wins, draws, and losses all accumulate across rounds. A draw is the optimal result and worth aiming for. If the AI wins, trace back to where your play diverged — most losses come from one missed block or a fork you did not see coming.

Frequently asked questions

Why does tic-tac-toe stop being fun for adults? Once both players know the optimal strategy, every game ends in a draw with no surprises. The interest in this AI version comes from learning that strategy well enough to hold the AI to a draw consistently.

Can I make the AI make a mistake? No. The AI always plays the move with the best possible outcome. Every mistake on the board will be yours.

Does it work on mobile? Yes. Tap any cell to play. The game works the same way on phones and tablets as on a desktop.