▸ Sandbox

Depth is how many half-moves ahead the computer searches: 1 means only its next move, 14 nearly the whole game. The numbers on the tinted squares are the score of the position after a move in that column, from the computer's point of view, in units of its evaluation function — not a win probability. Positive means the computer likes the position, negative means it does not.

Connect Four against the computer

Play Connect Four online against the computer. Solved in 1988: the first player wins with perfect play — if they can find it. Free, no sign-up.

What this game is

Connect Four looks like a children's game and takes twenty seconds to explain. It is also completely solved: with perfect play on both sides, the player who moves first wins.

Discs are not placed anywhere you like — they are dropped into a column and fall to the bottom. So you never have forty-two moves to choose from, only seven, one per column. But every move changes what the other player can reach on the floor above.

That is the real story of a game: less about building your own row than about who gets the square that matters once the stack grows up to it.

Rules

How to play better

A bit of history

Milton Bradley published the game as Connect Four in 1974 — a plastic rack the discs drop into with a satisfying clack. Similar games had been sold before, but this is the version that went around the world.

In 1988 the game was solved, independently and almost simultaneously, by James Allen and Victor Allis. The answer: with perfect play the first player wins, and the only winning first move is the centre column. Allis wrote his solution up as a master's thesis, building a program on nine strategic rules rather than on raw search.

None of which makes the game dull to play: knowing that a win exists and being able to find it are different things. The same thing happened to draughts and to Nine Men's Morris — all three are in our reference of solved games.

About the levels

Easy builds no tree at all. It checks two things: can it win right now, and are you about to win next move. If neither, it drops a disc near the middle, slightly at random. A double threat beats it every time — it only ever sees one.

Hard searches six plies with alpha-beta and scores the position over all sixty-nine windows of four that fit on the board: three of its own with an empty square is a plus, three of yours a bigger minus, and a window holding both colours is worth nothing, because nobody can ever win in it.

Expert is the same search with time-limited deepening: four plies, then five, and so on for about a third of a second. It tries columns from the centre outwards, because with alpha-beta the move order decides how much of the tree can be cut away. On an empty board it reaches ten to twelve plies; near the end of a game it sees all the way to the finish.

Where to go from here