← Connect Four against the computer

Connect Four Strategy: How to Win Moving First

Positions on this page were checked with a perfect solver, and everything about the computer levels with the game's own code. Columns are lettered a to g from the left, rows counted 1 to 6 from the bottom.
The short answer

Connect Four is solved: the first player wins with perfect play, but only by dropping the first disc in the centre column — a start in the next column over only draws, and any other start loses. You always move first here. Play near the centre, build threats rather than rows, keep your threats on odd rows (1, 3, 5), never drop a disc directly under the opponent's winning square, and aim for two threats at once.

Why the centre column decides everything

A disc is worth as many possible fours as it can belong to. There are 69 ways to make four in a row on this board — 24 across, 21 up, 24 on the diagonals — and they are not shared out evenly:

Rowabcdefg
6 (top)3457543
546810864
45811131185
35811131185
246810864
1 (bottom)3457543

A square in the middle of the centre column belongs to 13 fours, a corner to 3. Counted by column, 51 of the 69 fours pass through the centre column and only 15 through an edge one. That is why every strong player, and every engine, starts from the middle and keeps returning to it.

The first disc. Only the centre (✓) wins with perfect play; the two columns beside it draw; the four outer columns (✗) lose.

The win from the centre is a narrow one: with perfect defence the first player only completes a four with the very last disc they have, the 21st. Knowing that a win exists is not the same as finding it — but it tells you which side of the board to fight on.

Count threats, not rows

A threat is three of your discs in a line with the fourth square still empty. A threat whose square can be filled right now gets blocked; a threat whose square hangs in the air — with an empty square under it — stays on the board and shapes the whole game. Games are won by two threats at once, because only one can be blocked.

Three on the bottom row with both ends open: two threats (✓) at once, and the opponent can block only one.

The bottom row is where such traps are cheapest to set early: the squares are playable immediately, so an open three there is two threats on the spot. Higher up, threats are slower but more dangerous, because they wait.

Never play under a threat

If the opponent has a threat on a square that hangs in the air, the square under it is poison: whoever drops a disc there lets the other side complete the four on top. This is the single most common way games are thrown away.

O has three on the second row with both ends open. Neither end can be filled yet — and a disc under either of them (✗) hands O the win. X has to play elsewhere.

The same rule works for you: a threat of yours that the opponent cannot block without first filling the square under it is worth more than a threat that can be blocked at once.

The odd-even rule

Late in the game the board fills up, and someone runs out of safe moves. Who it is can be worked out in advance. With 42 squares and you moving first, the squares you are forced to take at the end fall on odd rows, and the opponent's on even rows. So, as Victor Allis showed when he solved the game in 1988:

  • The first player wants threats on odd rows — 1, 3 and 5, counted from the bottom.
  • The second player wants threats on even rows — 2, 4 and 6.
  • A threat on the wrong row is not useless, but it usually does not win by itself.
X (you, moving first) threatens e5, on an odd row, along the diagonal from d6 to g3. Fill the other free squares; O runs out of moves and must play e4, and X takes e5 with its last disc. Playing e4 yourself (✗) only draws.

The engine on this site does not know this rule: its evaluation counts threes and twos in each line of four but never looks at which row a threat sits on. In long games that is exactly where it can be outplayed.

How to beat each level on this site

You always play blue and always move first, so in theory every level is beatable. In practice:

Easy builds no search tree. It takes a win if it has one, blocks your immediate threat (only the leftmost one if there are two), and otherwise drops a disc at random, weighted towards the middle. It never checks whether it is playing under your threat. Following five rules — win, block, never play under its four, make a double threat when you can, and take the square where it could make one — won 94% of 20,000 simulated games. Win, block and play near the centre alone won 73%.

Hard searches six moves ahead with no randomness and no clock, so it answers the same position the same way every time. That makes it beatable by a fixed line. Drop your discs in these columns: d, f, f, c, d, d, g, f, e, g, c, e, e (counting from the left: 4, 6, 6, 3, 4, 4, 7, 6, 5, 7, 3, 5, 5). Hard answers c, c, g, f, d, g, d, f, c, d, c, e, and your thirteenth disc completes the row d4–g4. Each of your moves keeps a theoretically won position, and the line was replayed against the game's own code.

Expert searches for about a third of a second per move, going deeper until time runs out — nine to eleven moves ahead in the middle game on a fast computer, fewer on a slow phone. Because its depth depends on the device, its answers vary, and no memorised line works against it. A perfect player still wins every time: we played the solver against Expert at four different speeds and won all four games, in 17 to 20 moves. For a human, that means playing the centre, counting threats, keeping them on odd rows and never playing under one — for the whole game.

The 1958, 1977 and 1997 eras and the depth slider on the game page are a laboratory: they replace the level, and games played with them are not counted in the score.

The mistakes that lose games

  • Dropping a disc directly under the opponent's winning square. It is the most common losing move there is.
  • Building long rows instead of threats. Three in a row with both ends blocked is worth nothing.
  • Drifting to the edge columns early. They belong to the fewest fours; keep them for later, when a move there gives little away.
  • Making threats on even rows when you moved first. They are easy for the opponent to live with.
  • Blocking one threat and missing the second the opponent's last disc created.

Questions and answers

Is Connect Four solved?

Yes. James Allen and Victor Allis solved it independently in 1988: with perfect play the first player wins. The win requires starting in the centre column and is completed only with the first player's last disc.

What is the best first move in Connect Four?

The centre column — it is the only first move that wins with perfect play. The columns next to it lead to a draw, and the four outer columns lose.

Can the first player always win at Connect Four?

In theory, yes, starting in the centre. In practice the winning line is long and narrow: the defence holds out until the board is almost full, so a single slip turns the win into a draw or a loss.

What is the odd-even rule in Connect Four?

When the board fills up, the first player ends up forced onto odd rows and the second onto even rows (counting from the bottom). So the first player wants threats on rows 1, 3 and 5, and the second player on rows 2, 4 and 6.

How many ways are there to get four in a row?

69 on the standard 7×6 board: 24 horizontal, 21 vertical and 24 diagonal. A centre square belongs to 13 of them, a corner to 3.

How do you beat the computer at Connect Four?

On this site, Easy falls to simple traps such as an open three on the bottom row. Hard is deterministic and loses every time to a fixed line given on this page. Expert can only be beaten by near-perfect play: centre, threats on odd rows, and never playing under a threat.

What is a double threat?

Two squares that would each complete a four for you, at the same time. The opponent can block only one. Almost every decisive game ends with one.

Can the second player win at Connect Four?

Only if the first player makes a mistake. Against a first player who does not open in the centre, the second player can hold a draw or win.

Play Connect Four against the computer →
Where to go from here
To cite this page: “Connect Four Strategy: How to Win Moving First”, You vs Computer, https://youvscomputer.com/games/connect4-strategy.html