Minimax vs Alpha‑Beta
It's X's turn
Plain Minimax
Best Move: —
Value: 0
Nodes: 0
Time: 0.00ms
Alpha‑Beta
Best Move: —
Value: 0
Nodes: 0
Time: 0.00ms
Tic‑Tac‑Toe AI Guide
1. What is Tic‑Tac‑Toe?
A simple game on a 3×3 grid. Two players (X and O) take turns marking empty squares. The first to get three in a row (horizontally, vertically, or diagonally) wins. If all squares fill without a winner, it’s a draw.
2. How does the AI think?
The AI imagines all possible moves and scores each final outcome:
Steps the AI follows: 1. Look at every empty square on the board. 2. For each square: a. Imagine the AI places an O there. b. Check the game result: - If the AI (O) wins: score = +1 - If you (X) wins: score = -1 - If the board is full without a winner: score = 0 c. If the game is not over, switch turns and repeat these steps to see future outcomes. 3. After scoring all possibilities, pick the square with the highest score for the AI.
3. Why it works
- It finds every path from now until game end.
- It scores wins, losses, and draws as +1, –1, and 0.
- It picks the move with the best score for O.
4. Minimax vs Alpha‑Beta
Both methods search game outcomes, but differ in efficiency:
- Minimax: Explores all possible moves and counter‑moves without skipping. Simple but can be slow.
- Alpha‑Beta pruning: Keeps two values,
alpha
(best for maximizer) andbeta
(best for minimizer). If a branch cannot improve the final decision, it skips exploring it. - Result: Alpha‑Beta visits far fewer positions, making decisions faster, especially in deeper games.
5. Try it yourself
Play a few moves and watch the “Nodes Visited” stats:
- Notice how Minimax’s node count grows quickly, while Alpha‑Beta stays lower.
- Experiment with different board positions to see pruning in action.
Game Tree
3
+Start
Losing Branches are ignored by Alpha-Beta.
Move Heatmap
Perspective:
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
0.00
Win (=1)
Draw (=0)
Loss (<0)
The map demonstrates what O or X sees depending on X's move