🔴 solved-game minimax opponent

Connect Four

Drop discs, get four in a row before the AI does. The opponent plays real alpha-beta minimax, not a coin flip — no waiting for a match, no weak "easy mode" pretending to be smart.

Your move — click a column.
Wins: 0  ·  Losses: 0  ·  Draws: 0

How it works

The AI opponent runs a real minimax search with alpha-beta pruning, looking ahead 3, 5, or 7 moves depending on difficulty — at the search's depth limit, it scores each board with a heuristic that rewards controlling the center column and scores every possible 4-cell window (horizontal, vertical, both diagonals) based on how many of your discs versus the opponent's discs occupy it. Alpha-beta pruning skips branches that can't possibly change the outcome, letting it search deeper without brute-forcing every possible sequence.

FAQ

Can the AI be beaten, even on the hardest setting?
Yes — Connect Four is a solved game where the first player wins with perfect play, but this AI only searches a limited depth (up to 7 moves ahead on "Tough") rather than solving the full game tree, so it can still be out-maneuvered, especially early in the game before its lookahead reaches the endgame.
Why does the AI sometimes take a moment before moving?
A short delay is added deliberately before the AI's move, but the underlying minimax search itself explores every legal move to the chosen depth — "Tough" mode with 7-ply lookahead genuinely evaluates far more board positions than "Casual" at 3-ply, even though alpha-beta pruning cuts out branches that can't affect the result.

Free, unlimited, no account. If this saved you a paid tool, a small thanks is appreciated.

Say thanks — $3