Connect 4 Solver — Find the Perfect Move

Drop discs to set up any position, then let a perfect-play engine reveal the best move — and which columns win, lose or draw. Everything runs in your browser, nothing is uploaded.

How to Use the Solver

Click a column to drop a disc — reds and yellows alternate automatically, red first, just like a real game. Recreate the position on your board, then press Find best move. The solver marks the strongest column with a , labels any column that forces a Win or a Loss, and tells you whose move it is analysing. Undo takes back the last disc; Example loads a sample position to try.

How the Solver Works

Connect 4 is a solved game — with perfect play the first player wins by moving in the centre column. This tool plays out the game tree using negamax with alpha-beta pruning and a transposition table over bitboard positions, scoring forced wins and losses exactly and evaluating everything else by threats and centre control. For each legal column it looks ahead many moves, then ranks them from the mover's perspective. It all runs on your device in a fraction of a second, and your board never leaves the browser.

Frequently Asked Questions

How do I set up a position?
Build the position you are stuck on by clicking a column to drop a disc. Discs alternate automatically — red first, then yellow — so you set the board up by playing the game out. Use Undo to take back a drop, or Clear to start again from an empty grid. When the board matches yours, press Find best move.
Does it play perfectly?
The Connect 4 solver searches the game tree with negamax, alpha-beta pruning and a transposition table, and reports forced wins and losses exactly. On mid-game positions, where the remaining tree is small enough to exhaust, that means perfect play. From the opening it returns the best move within its search depth instead, in well under a second.
Who moves first?
Red moves first, following the standard Connect 4 convention. The solver works out whose turn it is from the number of discs already on the board, then analyses the best move for that player. If you want yellow on move instead, drop one more disc so the disc count matches the turn you want.
What do the Win and Loss labels mean?
The Win and Loss labels sit on each playable column, read from the point of view of whoever is to move. Win means that column forces a win with perfect play, and Loss means every continuation from it loses however the game goes. A plain best-move marker means no result is forced yet, but that column is the strongest available.
Is anything uploaded?
No — nothing you enter is uploaded. The board and the whole search run in your browser, so no position is sent to a server. Closing the tab clears the game completely.

Related Solvers & Games

Prefer to play? Take on the AI Connect 4 game. Solving other games? Try the Sudoku Solver or the Minesweeper Solver, or browse all AI solvers & analyzers.

Add This Connect 4 Solver to Your Website

Put the Connect 4 Solver on your own page — free, no sign-up, no watermark. It runs entirely in your visitors' browsers. Copy the snippet and paste it into your page's HTML.

The credit line under the widget links back to LK Forge — please keep it so others can find it too.