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.
- Red stone at row 6, column 1
- Red stone at row 6, column 2
- Red stone at row 6, column 3
- Yellow stone at row 6, column 6
- Yellow stone at row 6, column 7
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.
- Copy link to position puts the whole game in the URL, so you can share a position or come back to it later.
Key positions to try
Each of these opens the board at that position, with the engine's verdict alongside it.
- The centre openingThe only first move that wins. Every other column draws or loses.
- Answering the centreRed has taken the middle. See how little Yellow can do about it.
- A losing edge openingRed opens on the outside column and hands the win to Yellow.
- A forced blockOne column is playable without losing on the spot. The engine names it.
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.
Can I share a position?
Yes. Copy link to position writes the move list into the URL, so anyone opening that link sees the same board and the same analysis. The link works offline too, since the solver runs in your browser.