Lesson 6

Never-Lose Tic-Tac-Toe

Play against an AI that explains the safe move and never gives away a win

Can you beat the AI?

Story: This computer is not lucky. It is just very good at looking ahead.

Try it. Play tic-tac-toe against the computer. The AI uses a strategy called minimax. That is just a grown-up name for: look ahead and pick the safest move.

Your turn - you play X
X wins: 0 Draws: 0 O wins: 0
AI checklist
1. Win now if possible 2. Block your line 3. Take a strong square 4. Keep the safest future

Watch the note under the board after each AI move. It will tell you what the computer was trying to protect or block.

If mistake mode is off, tic-tac-toe ends in a draw with perfect play.

How the AI thinks

Check for a win

First the AI asks, "Can I win right now?"

Block danger

If not, it asks, "Do I need to block your line right now?"

Stay safe

Then it picks the square that keeps the future safest.
1 / 3

The board is small, so the computer can check lots of possible futures very quickly. It sorts endings into:

A solved game

We say tic-tac-toe is solved because the best move is known from every board position. That means the computer is not guessing. It is following a map of safe answers.

For the position below (your turn, you play X):

X | X | _
---------
O | O | _
---------
_ | _ | _

The best move is position 3 (top-right). That wins right away for X.

Why? Because X gets to finish the top row before O can finish the middle row.

The small-board lesson

Tic-tac-toe is a great first strategy game because the board is tiny. That lets you feel the whole idea clearly:

Practice

With perfect play from both sides, what is the result of tic-tac-toe?

If the AI can win right now, what should it do?

Why is the center square often strong?

What does it mean that tic-tac-toe is solved?