Iris

Status Your turn
Difficulty

About this experiment

Connect Four is one of the most elegant solved games in combinatorial game theory. In 1988, Victor Allis proved as part of his master's thesis at Vrije Universiteit Amsterdam that the first player can always force a win with perfect play. Independently, James D. Allen published the same result. The proof required evaluating millions of positions using a knowledge-based approach combined with exhaustive search. The game has 4,531,985,219,092 possible positions, making brute-force analysis a substantial computational challenge even for modern hardware.

The AI in this simulation uses the minimax algorithm with alpha-beta pruning, one of the foundational techniques in adversarial search. Minimax works by recursively evaluating all possible future game states, assuming both players play optimally. At each level, the maximizing player (the AI) picks the move with the highest score, while the minimizing player (you) is assumed to pick the lowest. Alpha-beta pruning dramatically reduces the search space by eliminating branches that cannot possibly influence the final decision — if the AI has already found a move guaranteed to score 10, it need not fully explore a branch where the opponent can force a score of 5.

At the "Hard" difficulty, the AI searches 7 moves deep, evaluating tens of thousands of positions in milliseconds. Its evaluation function considers central column control, connected pieces, and threats. Despite this sophistication, it is not perfect — the solved strategy for Connect Four requires looking much further ahead. This means a sufficiently skilled player can still beat it on hard difficulty, though it will rarely miss a tactical shot. The game nicely illustrates how exponential branching limits brute-force search: each additional depth level multiplies the positions to evaluate by roughly 7, so going from depth 7 to depth 14 would require about 7 million times more computation.