PlayNook

Connect Four Board Sizes: Who Wins on Each

variantsstrategy

Six four-in-a-row frames of increasing size standing side by side on a table, from four by four up to nine by seven, each partly filled with red and yellow discs

Want to try it? Four in a Row is playable right here.

Play Four in a Row

Everyone who has heard anything about this game has heard the one fact: on the standard board the player who moves first wins with perfect play. It is true, it was proved in 1988, and it is almost always stated as though it were a property of the game.

It is not. It is a property of seven columns by six rows. Take away one column and it becomes a draw. Make the board six wide and four high and the second player wins. Widen an eight-column board by one row and the winner changes sides — then changes back when you add another.

There is no tidy rule connecting these answers. Each size has to be worked out on its own, which is exactly why anybody bothered to compute them.

The table of solved board sizes

Widths across, heights down.

A grid of board sizes from 4 to 10 columns and 4 to 10 rows, each cell marked first player, second player or draw, with seven cells outlined in gold as recomputed
Results from John Tromp's collection of solved sizes. The seven outlined in gold we recomputed ourselves — that is the subject of the second half of this article.

Three things fall out of it that are worth more than the standard fact.

A board four or five columns wide is always a draw

Every height that has been solved, from four rows up to eleven, comes out drawn on a four-wide or five-wide board. Not "usually" — every single one.

That is a useful thing to know if you are drawing a board on paper for a child. On a narrow sheet neither player can be losing from the start, so a game lost there was lost to something specific and fixable.

Adding one row can hand the game to the other player

Look down the width-8 column. Five rows high it is a first-player win. Six rows high it is a second-player win. Seven rows, first player again. Eight rows, second player again.

The outcome alternates with the parity of the height, and that is not a coincidence — it is the odd/even threat rule showing through at the scale of whole boards. More on that below.

Seven columns is a lucky number

At six rows high, a six-wide board is a second-player win and an eight-wide board is a second-player win. The seven-wide board between them is the only first-player win in its row. The standard board is not the middle of a trend; it is an exception.

Why do narrow boards always draw?

The obvious guess is that there is simply less room. That is true but not precise, and the precise version is more interesting.

Four boards of six rows and increasing width, from four to seven columns, each labelled with the number of possible lines of four: 24, 39, 54 and 69
Every extra column adds exactly fifteen lines of four. The count climbs evenly and the outcome does not — it jumps from draw to second player to first.

Count the possible lines of four on each board and the numbers rise in a perfectly straight line: 24, 39, 54, 69 — fifteen more for every column you add. But the outcomes go draw, draw, second player, first player.

So it is not the number of lines that decides it. What matters is whether the first player can build two threats at once that the opponent cannot answer one at a time. On a narrow board the lines overlap so heavily that blocking one usually blocks the other as well; there is no room to separate them. Somewhere between five and six columns, separating them becomes possible, and the game stops being a draw.

Why we recomputed seven of them

Because a table is only as good as its weakest citation, and this one is copied around the internet without anyone checking. So we wrote a solver — bitboards, alpha-beta with a null-window search, a transposition table, and the pruning that discards any move after which the opponent wins immediately.

The point was never to beat the published numbers. It was to find out whether we could reproduce them, because a solver that agrees with a known table on seven boards is a solver whose answers elsewhere can be trusted.

BoardResultPositions searchedTime
4×4Draw9,4200.1 s
5×4Draw54,4451.0 s
6×4Second player wins545,5868.1 s
7×4Draw5,067,03782.7 s
4×5Draw25,6260.4 s
5×5Draw664,20510.0 s
6×5Draw3,772,78263.6 s

All seven match the published values.

The bug the small boards hid

Writing a solver that produces plausible answers is easy. Writing one that produces correct answers is a different job, and ours was wrong the first time in a way worth describing, because it is the classic failure of every bitboard game program.

The position is stored as two numbers: all the discs, and the discs belonging to the player to move. After a move the sides swap — and the swap has to be made against the old set of all discs, the one from before the new disc landed. Do it against the new one and the disc just played is credited to the opponent. Every position after that describes a game in which nobody owns their own last move.

The first three boards gave exactly the published answers anyway, because they are all draws, and a draw survives a great deal of nonsense.

What caught it was checking the solver's win detection against the game engine — two independently written pieces of code — over fifteen thousand random moves. They disagreed a thousand times. After the fix they agreed on every single one.

And two reference values that were wrong

More embarrassing and more instructive: two of the values we were checking against had been typed from memory. We had 6×4 down as a draw and 6×5 as a first-player win. The solver said second-player win and draw.

The solver was right both times. If you write down what you expect before you measure, you find out which of the two was guessing.

Why 7×6 is not on our list

A logarithmic chart of positions searched against squares on the board, rising from nine thousand at sixteen squares to five million at twenty-eight, with a dashed extrapolation to about a hundred billion at forty-two squares
Roughly a factor of ten for every two squares added. At seventy thousand positions a second, the standard board is days of computation, not minutes.

Sixteen cells is nine thousand positions. Twenty-eight cells is five million. The standard board has forty-two, and needs something on the order of a hundred billion.

Our solver runs at about seventy thousand positions a second in JavaScript. That is days of work, not minutes, so we did not do it. The first-player win on 7×6 in the table belongs to James D. Allen, who announced a solution in October 1988, and to Victor Allis, who announced an independent one fifteen days later.

Saying so is the point. A page that reprints a table and implies it did the work is worth less than one that tells you where each number came from.

What board size has to do with odd and even

The alternating pattern down the width-8 column is not a curiosity. It is the same rule that decides games between strong players on the standard board.

A seven by six board with rows numbered from the bottom, rows one three and five shaded red for the first player and rows two four and six shaded yellow for the second
If a column simply fills from the bottom, it is already settled who ends up on which row. Everything about threat parity follows from this picture.

If a column fills from the bottom, whose disc lands on which square is decided before either player gets there. Counting the bottom row as row 1, the player who moved first collects the odd rows and the second player the even ones.

So a threat — three of your discs with a gap that would complete the line — is worth very different amounts depending on the row that gap sits in. On a row that will be yours, you only have to keep it alive. On a row that will be theirs, it is not a threat at all: it is a square you are about to hand over.

Now change the height of the board. The top row changes parity, which changes who is favoured in the endgame, which is why width 8 flips between first-player and second-player wins with every row you add. The board size and the parity rule are the same fact seen from two distances.

Try the sizes instead of taking our word for it

Every size discussed here is playable:

  • Four in a Row in the browser has a board size menu under the board: 4×4, 5×4, 6×4, 6×5, the standard 7×6, 8×7 and 9×7, plus a nine-wide board where you need five in a row. Against a computer at three strengths, or against a friend online with a shared code.
  • The printable sheet prints four of them with two boards to a page, and counters to cut out.

The one worth ten minutes is 6×4. It looks like a slightly small version of the normal game and it is a second-player win — so if somebody offers to let you go first on it, they are not being generous.

  • Pop Out — the official variant that lets a player pull a disc back out of the bottom of a column, and what that does to everything on this page.
  • How a computer plays sea battle — the same approach applied to a different game: count first, then claim.