gizmobench

Connect Four Analysis

Type a move history such as 4453, one digit per column, or drop discs on the board, and every legal column gets a result: which side wins and on which move, a draw, or an estimate. A result is marked exact only when the search followed every line that could change it to the end of the game; when the time limit you set, from 0.1 to 5 seconds, stops the search first, the columns it has not proven keep the last depth that finished and are labelled estimates rather than shown as solved. Immediate wins, forced blocks and each side's threat cells are listed beside the board, and you can undo and redo, play the computer from the same search, or save the position and its analysis as JSON.

Computer opponent
seconds
boardloading

Arrow keys move between columns; Enter, Space or a digit from 1 to 7 drops a disc. Each column also has a Play button in the analysis list.

history
none yet, empty board
full
no column
threats
Red: none
Yellow: none
this move
no immediate win or block this move
One digit per move, the column from 1 to 7, Red first. Spaces and commas are ignored.
analysislimit 1 s

Loading any saved game.

  • 1not scored yet
  • 2not scored yet
  • 3not scored yet
  • 4not scored yet
  • 5not scored yet
  • 6not scored yet
  • 7not scored yet
depth
none
time
none
To move
Red, move 1
Best column
not scored
Search
none yet
Legal columns
7 of 7

Analysis as text
Connect Four: 0 moves, Red to move
history  (empty board)
  1 2 3 4 5 6 7
  . . . . . . .
  . . . . . . .
  . . . . . . .
  . . . . . . .
  . . . . . . .
  . . . . . . .
no immediate win or block this move

Examples

Each one goes into the history field; the playable ones load onto the board, and the two rejected histories show the message you get instead.

  • Move history 121213Red to move, move 7
    immediate Red win in column 1, exact; after it the game is over and further moves are rejected
  • Stopped by the time limithistory 44, limit 0.1 s
    the search stops at 0.1 s and keeps its last completed depth; a column is exact only if every line that matters was followed to the end
  • A 30-move endgame12 cells left, Red to move
    column 3: Red wins on move 37; column 4: draw; column 2: Yellow wins on move 38; column 5: Yellow wins on move 36; all exact
  • History 1111111a seventh disc in one column
    rejected at move 7, column 1 is full
  • History 12121212a move after a win
    rejected at move 8, Red won at move 7

1 2 3 4 5 6 7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Common questions

Is this a perfect Connect Four solver?
Only where it says exact. A column is marked exact when the search has followed every line that could change its result to a win, loss or draw, with no guesswork where it stopped. In the first few moves of a game that takes far longer than the 5 second maximum, so those columns are estimates from the deepest search that finished. Later positions, with fewer empty cells, are often proven well inside the limit.
What does 'Red wins on move 29' mean?
Moves are counted from the first disc of the game, so move 29 is the 29th disc dropped, which is Red's because Red plays the odd moves. An exact result means that with best play by both sides from here, the game ends with Red's four in a row on that move. An estimate that shows a win reads 'wins by move 29': the search found a forced win for that side within the depth it finished, and a faster one may exist.
How do I enter a position?
Type the move history into the Move history field: one digit per move, the column from 1 on the left to 7 on the right, starting with Red. 4453 means Red in column 4, Yellow in column 4, Red in column 5, then Yellow in column 3. Spaces, commas and hyphens are ignored. You can also drop discs by clicking a column, with the arrow keys and Enter, or by pressing a digit from 1 to 7 while a column has focus.
Why was my move history rejected?
The history is replayed from an empty board and stops at the first move that cannot happen: a seventh disc in a full column, any move after a side has connected four, a 43rd move, or a character that is not a column digit. The message says where the history stopped and why, for example 'Move 7 is column 1, which is already full.' or 'Character 3 is 8, but columns run 1 to 7.'
What do the depth and the time limit mean?
Depth is how many moves ahead the search looked from this position; the number of empty cells is the most it can be. The search deepens one move at a time, and when your time limit runs out, the depth in progress is thrown away and the last completed one is shown. A faster device finishes more depth in the same limit, so estimates can differ between devices, but an exact result is the same everywhere.
Does the computer opponent play perfectly?
It plays the best column of the same search you see, within the same time limit. When every column is marked exact, that is the best result available; otherwise it plays the best estimate and can make mistakes, most often early in the game. Choose the color it plays, or turn it off to analyze both sides yourself.
Is anything sent to a server?
No. The search runs in a background worker in your browser, the game and settings are saved in this browser's local storage, and the .json button saves a file to your device. There are no accounts, online opponents, rankings or betting.

A column marked exact was resolved to a win, loss or draw at the end of the game on every line that could change its result, with no heuristic cutoff, and a move that wins at once is always exact. Any other result is an estimate from the last search depth that finished inside your time limit of 0.1 to 5 seconds, so it can be wrong, and a slower device may reach less depth. The computer opponent plays the best column of that same search, and there are no online opponents, rankings or betting.