How to use the Connect 4 solver
The Connect 4 solver needs the position you are stuck on. In Drop discs mode, tap the columns in the order the game was played: red always moves first and the colors alternate. If you only have a picture of the board, switch to Place freely and paint each disc red or yellow. The solver checks that every disc rests on the bottom or on another disc and that red has the same number of discs as yellow or one more, and it tells you exactly what is wrong if not. You can also type the move list, such as 4453, one digit per column.
A score appears above every column, and the table explains it in words. The column with the black badge is the best move. Switch to Play against the solver to try the position yourself; Undo takes back your move and the reply.
How to read the scores
The scores use the convention from Pascal Pons' well-known Connect 4 solver. 0 means the game ends in a draw if both players make no mistakes. A positive score means the player to move wins by playing that column, a negative score means they lose against perfect defense. The number says how soon: it is 22 minus the number of discs the winner has used when the four is completed. So +18 is a win with your 4th disc, +1 a win with your 21st and very last disc, and -17 means the opponent connects four with their 5th disc. A higher score is always better for you.
How the solver works
It is a perfect solver: it does not guess or use a rule of thumb, it searches the game to the end. The board is stored as two bit patterns (one for all discs, one for the player to move), so finding four in a row is a handful of bit operations. The search is negamax with alpha-beta pruning, which skips moves that cannot change the result. Moves that would hand the opponent a win right away are never explored, moves that create the most threats are tried first, then central columns. Results are remembered in a table of several million positions, and the exact score is narrowed down with a series of yes-or-no searches (is the score above 0? above 5?), each much faster than a full search. Win, draw or loss is settled first, because that question is the fastest to answer, and the exact score follows.
We tested it against a plain brute-force search that looks at every possible continuation, on 250 late-game positions, column by column, and on mirror-image positions, which must score the same. Every result matched.
The opening book and early positions
Connect 4 has about 4.5 trillion reachable positions. In the middle and end of a game the solver usually answers in well under a second. Near the start the search is much longer, so the solver carries an opening book: about 45,000 positions with up to 10 discs, each with a proven result (win, draw or loss). We built it by running this same solver on the empty board and on every position with two discs, keeping every position it proved along the way. Our own run confirms the known result: the first player wins only by starting in the middle column, columns 3 and 5 lead to a draw, and columns 1, 2, 6 and 7 lose. With the book, win, draw or loss appears almost at once even on an empty board; the exact score (how soon) can still take minutes with few discs, so the solver shows what it has proven as it goes: ≥0 means at least a draw is proven, +? a win whose length is still being worked out. Connect 4 was first solved in 1988, by James Dow Allen and, independently, Victor Allis.
Worked example
Press Example. Fourteen discs are on the board and red is to move. The solver scores columns 2 and 5 at +11: red wins with the 11th disc, four more moves of its own, whatever yellow does. Column 4 is also a win but slower (+9), column 6 wins with the 19th disc (+3), column 1 only draws, and columns 3 and 7 lose. Tap column 2 and watch the scores flip to yellow's point of view.
To play a whole game against the computer or a friend, open Connect 4 online, which has a Best move button too. On the 3 by 3 grid, the tic tac toe solver marks every square as a win, draw or loss in the same way.
Solver tested . Found a problem? Tell us.
Questions
Is Connect 4 solved?
Yes. It was solved in 1988 by James Dow Allen and, independently, by Victor Allis. With perfect play the first player wins, but only by starting in the middle column.
What does a score of 0 mean?
The game ends in a draw if both sides play perfectly from that position. A positive score is a win for the player to move and a negative score a loss; the bigger the number, the sooner the four is completed.
Why does the solver take long with only a few discs on the board?
It plays the game out to the end in its head, and early on there are billions of possible games. Win, draw or loss comes almost at once thanks to the opening book; the exact number of moves can take minutes with only a few discs. Late positions are answered almost instantly.
Can I enter a position from a photo?
Yes. Choose Place freely and paint each disc. You do not need the move order; the solver only checks that the discs could have been played (no floating discs, and red has as many discs as yellow or one more).
Does the solver work for other board sizes?
No. It solves the standard board of 7 columns and 6 rows with four in a row to win.