Back to blog

How to win at Connect Four every time

strategy
guide
theory

As Connect Four is a solved game, when the player who goes first (red) plays perfectly it is impossible for the other player (yellow) to win.

Whilst computers can do this every time, it is very difficult for a human to achieve this consistently.

One possible winning state if both players play perfectly:

Connect four end state with perfect play

Perfect play

  • Important first step: must be playing as red
  • Control the center, play optimally based on the memorised optimal play for red
  • Continue following a known line as memorised or react to yellow's mistakes, leveraging tactical knowledge to end the game sooner

This last step is where you must put the work in - the red player doesn't only need worry about the scenario in which yellow plays 'optimally' (taking as many turns as possible to lose). The yellow player is able to move the game into a non-standard position - they may technically lose faster, however, if the red player is not familiar with it they can make a mistake and let yellow back into the game.

For the red player, it is not feasible to memorise every possible position that yellow can force the game into. For this reason, a player wishing to play perfectly must employ a mixture of memorisation and leveraging of game fundamentals.

Learning to play optimally

Learning Connect Four can be split into two distinct parts:

  • Rote learn 'openings': by brute force memorising the first ~15 moves in a given line of play the player can reach a simpler position where the game can be reasoned about and they can use strategy and general rules to guarantee a win.
  • Developing fundamentals - by expanding the number of positions you can reason about you'll be able to spot winning moves without the need to memorise so deeply
    • You might memorise the most common openings, but if yellow makes a really bad mistake you won't have bothered to learn it and should be able to punish it regardless
    • This is quite a big topic with lots of tools, heuristics, and patterns to recognise, each of which expands the number of positions you can reason about so I plan on writing some future blog posts to expand on it

These work together — learn more of one, you need less of the other.

Tools

Some tools to assist in your improvement:

  • This website has a solver at /eval that can be used to reason about positions
  • The youtuber twoswap has published an anki deck that can be used to memorise openings
  • Discord user 2014MELO03 has developed a desktop application as a structured approach to learning openings
  • Test yourself by playing games at papergames.io and use the /analyse tool to check where you diverged from optimal play

References

This post was written with reference to the below sources: