Free puzzle tool · four in a row

Connect 4 Solver

This free Connect 4 solver checks a 7 by 6 board and shows proven outcomes for each move when its search finishes, in your browser.

Updated

Enter a Connect Four position

Tap a column to drop a disc. Red goes first; columns are numbered left to right.

Red to move.

Connect 4 solver facts at a glance

Sources: Victor Allis, A Knowledge-based Approach of Connect-Four, Pascal Pons’s solver tutorial, and John Tromp’s UCI Connect-4 dataset (1995, CC BY 4.0; packed and adapted for this solver). Updated .
Board7 columns, 6 rows; discs fall to the lowest empty cell
PlayersRed starts, Yellow plays second
GoalFour discs in a horizontal, vertical or diagonal line
Best openingColumn 4 wins with perfect play
Search limitEight seconds of search per position; outcomes appear as proven, and unfinished columns or move counts are marked
PriceFree; no account or download

How to use the Connect 4 solver

  1. Start a game. Tap a column to drop Red's first disc. Continue alternating red and yellow discs to reproduce your moves.
  2. Or set up a position. Press Set up my board, choose Red, Yellow or Erase, and tap individual cells. Tap the same color again to remove it.
  3. Check the board. Fill from the bottom without gaps. Red must have the same number of discs as Yellow or one extra.
  4. Press Solve position. Read the outcome for each available column. A win or loss count is measured in the winning player's moves from this position.
  5. Continue or share. Tap a column to play it and solve again, or copy a board link to return to the same position.

How the solver works

The solver represents each player's discs as bits and searches the possible continuations. It scores positions from the perspective of the player whose turn it is: a forced win is better than a draw, and a draw is better than a forced loss. Among wins it prefers the quickest; among losses it delays defeat. The score assumes the opponent also chooses the best reply, not that the opponent makes an accidental mistake.

Alpha-beta pruning skips branches that cannot change the answer, and a table stores proven score bounds. The search checks immediate wins, blocks threats and orders moves by potential winning spots. A worker proves each column's win, draw or loss first, then uses any remaining time to calculate winning distances. Results appear as columns finish. When a column is still unknown, even the best proven result might not be the best move overall.

For reachable positions with fewer than eight discs, the solver looks up every move in an opening book computed from John Tromp's UCI dataset (CC BY 4.0) and offline search. These results give win, draw or loss without move counts. The eight-second limit applies to later searches; loading the book can take additional time. A board link stores the discs in the address after the hash.

Why the first player wins

Connect Four is a solved game: on the standard board the first player can force a win by starting in the center and responding correctly to every defense. Victor Allis established the result in his 1988 thesis, A Knowledge-based Approach of Connect-Four, using strategic rules together with search. Starting in columns 3 or 5 instead permits a draw with perfect play; starting in columns 1, 2, 6 or 7 permits the second player to force a win.

That result does not mean every move after the center opening wins. A single move can turn a winning position into a draw or loss. Nor does a forced loss mean the opponent will necessarily find the winning line in a casual game. The labels describe what happens if both sides continue perfectly, and a finished game stops as soon as either player connects four.

Strategy tips: center and threats

The center participates in more possible horizontal and diagonal lines than an edge cell. Playing there often keeps more routes open, but it is not automatically safe: first check whether your opponent can win immediately. If they have three with a playable fourth cell, block it unless you can win on this move. Next, look for a double threat: two different winning cells that the other player cannot both block.

Gravity makes the row of a threat matter. A winning cell cannot be played until every cell below it is filled, and filling a cell may give the opponent access to the cell directly above. Count rows from the bottom: odd and even rows can favor different players depending on who will be forced to fill a column. Allis's thesis develops precise rules for these threats and their interactions. Parity is useful for planning, but it is not a substitute for checking immediate wins and the rest of the board.

Frequently asked questions

What is the best first move in Connect 4?

The center, column 4. With perfect play Red can force a win from that opening; columns 3 and 5 draw, and the four outer columns lose.

Can I enter a position from a real game?

Yes. Play the moves on the board or use Set up my board to place red and yellow discs, then press Solve. The solver checks gravity, disc counts and wins.

Does the solver always finish?

No. It searches for up to eight seconds. Difficult columns may remain unsolved; proven outcomes are kept even when their move counts are not computed.

What does a move count mean?

The count is the number of discs the winning player must still play from the position shown, including the chosen move if it belongs to that player. Both players choose their best continuation.

Can the second player win?

Yes, after a mistake or a losing opening. From the empty board, perfect play by the first player starting in the center prevents a second-player win.

Is this Connect Four solver free?

Yes. It is free, requires no account or download, and runs in your browser. A board link stores the position in the URL.

More puzzle solvers

Sorting puzzles

Grid and logic puzzles

Cards, words and colors

All tools