Connect 4 solver
Perfect-play analysis of any Connect 4 position.
Click a column to drop a stone, then watch the solver work out the best reply. It runs entirely in your browser — nothing is sent to our servers.
Engine evaluation
Calculating…
Running the solver in a background worker so the board stays responsive.
How to use
- Click any column to drop a stone — red plays first. The board turns alternate automatically.
- After each move the solver searches the game tree and highlights the column it recommends next.
- Use Undo to take back a move or Reset to start a fresh game. Your game is saved automatically in your browser.
- Turn off Highlight best move if you want to test yourself without the engine spoiling the answer.
Frequently asked questions
How strong is the solver?
It uses the same bitboard negamax algorithm as Pascal Pons' open-source solver with alpha-beta pruning, a transposition table and centre-first move ordering. From any mid- or late-game position it plays perfectly. On a nearly-empty board it may hit its time budget and return the best move found so far.
Does Red always win with perfect play?
Yes — Connect 4 was mathematically solved in 1988. The first player wins if they drop the first stone in the centre column and then play perfectly. Any other first move draws or loses.
Is my game saved?
Yes — the moves you've played are stored in your browser's local storage, so the board is still there when you come back. Nothing is sent to our servers; clearing your browser data will remove it.
Where does the solver run?
Entirely in your browser, inside a Web Worker so it doesn't block the board while it thinks. Because it's client-side you can use it fully offline after the first load.