Introduction

Connect Four is the rack-and-checkers game everyone has played: two colors, seven columns, six rows. You take turns dropping a disc into a column; it falls to the lowest free slot. The first to line up four in a row — horizontal, vertical or diagonal — wins.

It feels like a casual game of instinct and small mistakes. But Connect Four is completely solved. For every legal position, mathematicians know who wins with perfect play and which move keeps them on the winning path.

The headline result is crisp: on the standard 7×6 board, the player who moves first wins — but only if their very first disc goes into the center column. Any other opening, played out perfectly by both sides, lets the game slip to a draw or a loss.

Play the Perfect Engine

Here is a smaller Connect Four — 5 columns, 4 rows, connect four — small enough that the computer can search every future from the current position before each move. You play yellow; the engine plays red and plays perfectly.

<p class="hint">{{hint}}</p>
<div id="board" class="board"></div>
<div class="status" id="status">{{your_move}}</div>
<div class="btns">
  <button id="reset" type="button">{{new_game}}</button>
  <label class="who"><input type="checkbox" id="first"> {{engine_first}}</label>
</div>
* { box-sizing: border-box; }
body { font-family: system-ui, sans-serif; color: #222; margin: 0; }
.hint { font-size: .9rem; color: #444; margin: 0 0 .7rem; line-height: 1.45; }
.board { display: inline-grid; grid-template-columns: repeat(5, 52px);
         gap: 6px; padding: 8px; background: #1d3557; border-radius: 12px; }
.cell { width: 52px; height: 52px; border-radius: 50%; background: #f4f6f9;
        cursor: pointer; transition: transform .08s; }
.cell:hover { transform: scale(1.05); }
.cell.y { background: radial-gradient(circle at 35% 30%, #ffe066, #f1c40f); cursor: default; }
.cell.r { background: radial-gradient(circle at 35% 30%, #ff7a85, #e63946); cursor: default; }
.cell.win { box-shadow: 0 0 0 3px #0a7d33 inset; }
.status { font-size: 1rem; font-weight: 600; margin: .7rem 0 .5rem; min-height: 1.4em; }
.status.ok { color: #0a7d33; }
.status.bad { color: #c92f3c; }
.btns { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
button { font: 600 14px system-ui, sans-serif; padding: .45rem .9rem; border: 1px solid #1d3557;
         background: #1d3557; color: #fff; border-radius: 8px; cursor: pointer; }
.who { font-size: .85rem; color: #444; display: flex; gap: .35rem; align-items: center; }
// Code not found

Try to beat it. You can't — at best you draw. The engine isn't guessing or using tricks: for every move it runs minimax, exploring the entire game tree to the end and picking a move that, against any reply you could make, never lets it lose. This is exactly how the full 7×6 game was conquered, just on a board small enough to solve live in your browser.

The Real Complexity

What does it mean to solve a game? Not to play it well — to know the perfect outcome from every position.

  • The game tree is huge. The standard 7×6 board has about 4.5 trillion legal positions. Naively searching every line of play by brute force is far beyond hand calculation.
  • It is solved anyway. In October 1988, two researchers cracked it independently: Victor Allis (with a knowledge-based program, in his master's thesis) and James Dow Allen. The verdict: with perfect play, the first player wins, and the only winning opening is the center column.
  • Strongly solved. Connect Four isn't just "we know who wins from the start." Modern solvers (notably John Tromp's) give the perfect result for every position — that is a strongly solved game.
  • How. The engine in this article uses minimax: assume both players play optimally, score each leaf as win/draw/loss, and propagate those values back up. On the real board this needs clever pruning and endgame databases; on our tiny board, plain search suffices.

So Connect Four sits at the opposite end from open problems like P vs NP: its answer is fully known. The interesting limit here is size — the same exhaustive idea explodes on bigger boards and harder games like chess.

Where It Matters

"Find the best move when an opponent is fighting back" is a shape that shows up far beyond board games, and Connect Four is its clearest teaching example:

  • Game AI: the minimax-with-pruning that solves Connect Four is the ancestor of the engines behind checkers, chess and Go.
  • Adversarial decision-making: planning against a worst-case opponent — in security, auctions or robust control — is the same minimax reasoning.
  • Provable optimality: a solved game is a guarantee, not a heuristic. The same exhaustive certainty backs formal verification and correctness proofs.
  • Teaching limits: Connect Four shows both sides of the coin — a game small enough to solve completely, next to giants like chess where full search is hopeless.

Understand why Connect Four is solved and you've met adversarial search — the engine behind game AI and any "best response to a hostile opponent," a cousin of the search ideas in chess.

Conclusion

Connect Four hides a tidy secret: there is nothing left to discover about who wins. Start in the center and play perfectly, and as the first player you are guaranteed to win — a fact proven back in 1988 and since extended to every position on the board.

That makes it the friendly opposite of the open questions on this site. The catch is scale: the very same exhaustive search that tames a 7×6 grid drowns on bigger boards and on giants like chess. Connect Four is the game we fully conquered — a clean reminder that "solvable in principle" and "solvable in practice" are two very different lines.

Share this article

Pick a channel — or use your device's native share sheet.

Comments

Loading comments...

https://www.kipuhub.com/en/article/connect-four/Content licensed under CC BY-NC 4.0.