Skip to the board
BARRELHEAD

Four in a Row

Your move.

You play red and go first. Tap a lane and your piece slides down it. Four in a row wins: across, down or diagonally.

How to play

Pieces leftYour pieces:21The computer's pieces:21

Opponent
Start over?

Seven lanes, six places, four in a row

Four in a row, the game sold in stores as Connect Four, laid flat on the head of a barrel.

The board and the pieces

Seven lanes with six places in each. That makes 42 places. The store-bought game stands upright, and its pieces are dropped in from the top. Here the same board lies on its back: the lanes run away from you, and the edge nearest you, the one with the red bar, is the bottom.

Twenty-one pieces each. You play red and the computer plays white, unless you swap the colors under Settings. Between them the two sides have exactly enough pieces to fill the board.

The board starts empty. The first move is yours, unless you give it to the computer under Settings. Your color and the first move are separate choices there.

A move

Tap a lane. Your piece is set down at the far end of that lane and slides toward you until something stops it: the red bar if the lane is empty, otherwise the piece that went in before it.

You choose the lane, never the place. A piece always ends up in the free place nearest you. It cannot stop halfway, and it cannot go past a piece that is already there.

A lane holds six pieces. When it is full, nothing more can be played in it.

A piece that has stopped stays where it is. Nothing is ever moved or taken off the board during a game. The two sides take turns, one piece each, and you cannot pass.

The board with six pieces at the near end of three lanes. A red piece stands at the far end of the fifth lane, and a chalk arrow runs from it down the lane to a chalk ring on the place next to a white piece.
The red piece is set down at the far end of its lane and slides toward you. It stops in the place with the ring, against the white piece that was there first.

Four in a row

The first side to get four of its pieces in an unbroken row wins. The row can run across the lanes, along one lane, or diagonally.

There are 69 ways to do it. Twenty-four rows run across the lanes, 21 run along a lane and 24 are diagonal, twelve leaning each way.

A longer row wins too. A piece that joins two shorter rows can make five, six or seven in a row. That is a win like any other.

The game stops there. On this board the winning row gets a chalk loop around it before the pieces are cleared away.

How a game ends

Four in a row ends the game at once.

A full board with no row of four is a draw. That takes all 42 pieces, 21 from each side.

There is no other way to draw. Pieces never move, so a position cannot come back, and the game is over after 42 moves at the most.

Sources

Checked against the rules as Victor Allis gives them in his thesis on the game, and against the engine that runs this board. The numbers of rows are counted from the board.

Questions people ask

Who wins if nobody makes a mistake?

The side that moves first. The game on seven lanes and six places is solved: with perfect play from both sides, the first player wins, and only by starting in the middle lane.

Two people announced it independently in October 1988: James D. Allen, and Victor Allis, who wrote it up as his master's thesis at the Vrije Universiteit in Amsterdam. The win is not quick. Against the best defense it comes with the first player's last piece, the 41st of the 42 on the board.

What is the best first move?

The middle lane. It is the only first move that wins against perfect play.

  • The middle lane: a win for the side that started.
  • The lanes next to the middle: a draw.
  • The four outer lanes: a win for the other side.

Those are results with perfect play on both sides, published by people who have solved the game. Nobody at the table plays that way, but the middle is still the right habit.

Does it matter who goes first?

Yes, more than in most games on this site. The first player has a forced win, and the second player can only wait for a mistake. Between people the mistakes come soon enough for either side to win.

Here you can take the first move, give it to the computer, or take turns from game to game. The choice is under Settings.

Can I choose where in the lane my piece goes?

No. You pick the lane, and the piece goes as far as the lane is free. A tap high up in a lane and a tap low down do the same thing.

With Show moves on, a chalk dot in each lane marks the place where a piece would stop.

Why do the pieces slide here when they drop in the game I know?

Because this board lies flat. Everything on this site is seen from above, on the head of a barrel, so the upright rack has been laid on its back. The far end of a lane is the top of the rack, and the red bar nearest you is its floor.

The rules are the same. A piece goes to the lowest free place in its column, and here "lowest" means nearest you.

Does five in a row count?

Yes. Four is the least you need, not the exact number. A row of five or more can only come about when one piece joins two shorter rows, and it wins.

Can a game end in a draw?

Yes. If all 42 places fill up and neither side has four in a row, nobody wins. Between careful players that happens, because both sides spend the last part of the game refusing to play the one place that would let the other side win.

What if a lane is full?

Then it is closed for the rest of the game. If you tap a full lane, the board says so and waits for another choice. As long as the game is not over there is always at least one lane with room in it.

How many positions are there?

4,531,985,219,092. That is the number of different positions that can come up in a legal game, the empty board included, as counted by John Tromp. It is about four and a half trillion: far too many to learn, and few enough for a computer to work through.

What else is the game called?

Four in a line and four up are names that have been used for it. In stores it has been sold under a brand name since 1974, and that name is the one most people know it by.

Is a hint always the best move?

Usually it is proven, and the rest of the time it is the engine's best judgment. The hint comes from the engine at full strength. How often that is a proof and how often a judgment is set out under How the computer plays here.

How games are won

Start in the middle, and stay near it

Every row of four that runs across the lanes passes through the middle lane. There are only seven lanes, so four in a row sideways cannot miss it. The two places in the middle of that lane each lie on thirteen of the 69 rows, more than any other place on the board. A corner lies on three.

The outer lanes are the opposite. Across the lanes and diagonally, a piece there can only ever be the end of a row.

Look at the place your piece opens up

Every piece you play makes one more place available: the one right beyond it in the same lane. Before you tap a lane, look at that place. If the computer wins by playing there, your move hands it the game.

This is the most common way to lose. The move looked fine, and it was, except for what it uncovered.

Block three in a row at once

Three white pieces in a row with a free place at one end, and a piece able to stop there, is a win on the next move. Check for it before every move of your own, in all three directions.

If you can make four yourself, do that first. The game is over before the block is needed.

Make two threats with one piece

One winning place can be blocked. Two at the same moment cannot. The simplest case is on the row nearest you: three pieces side by side with a free place at both ends.

It takes two moves to stop, so it has to be stopped a move early. When the computer has two pieces side by side on the bottom row with room on both sides, put your piece next to them now.

The two rows of the board nearest the player. Three red pieces stand side by side on the bottom row, with two white pieces on top of them. The empty places at both ends of the red row have chalk rings in them.
Red has three in a row with both ends free. Either place with a ring makes four, and white can only fill one of them.

Stack one winning place on another

Two winning places of yours in the same lane, one right beyond the other, cannot both be stopped. When the computer blocks the nearer one, its piece is exactly what your next piece needs to stop against, in the place beyond it.

The engine here scores this formation higher than any other threat, for that reason.

A place nobody dares to play

A winning place that cannot be reached yet is still worth having. As long as the place in front of it is empty, neither side wants to fill that one: if the computer plays it, you win on top of it, and if you play it, the computer blocks.

Such a lane stands untouched while the rest of the board fills. In the end one side runs out of other moves and has to play it.

Odd and even places

Who runs out first is a matter of counting. The board has an even number of places, and the sides take turns. If every other lane is full, the side that moved first plays the first, third and fifth places of the last lane, counted from your end, and the other side plays the second, fourth and sixth.

So the side that moved first wants its waiting threats on the third or fifth place of a lane, and the side that moved second wants them on the second, fourth or sixth. Victor Allis set this rule out in his work on the game. It has exceptions, but it tells you which threats are worth setting up.

Use the hint as a second opinion

The Hint button asks the engine at full strength what it would play. When its lane is not the one you had in mind, look at the place your own move would have opened up, and at what the hint blocks, before you play either.

How the computer plays here

Five levels, one engine. The lower levels look a short way ahead and are careless on purpose. The top level knows the opening by heart and works most of the rest out to the end.

How it thinks

The computer tries its moves, your answers and its answers to those, as many moves deep as the level allows, scores the positions at the end, and plays the move that leaves it best off if you reply as well as you can.

The score is built on winning places: empty places where one more piece would make four. A winning place that can be played on the next move has to be blocked. One that cannot be reached yet stays on the board as a threat, and it counts for more when it lies on a place that suits the side, odd for the side that moved first and even for the other.

Two winning places stacked in one lane count for the most. Pieces in the middle lanes get a little extra, since more rows pass through them.

All of this happens on your own device, in your browser.

Beginner

Looks at its own move and your answer, and cares mostly about its own rows. In a little more than half of its moves it is careless and looks at its own move only. That is when it fails to block three in a row.

Easy

Looks just as far, but with the full score: it blocks, and it sees when it can make two winning places of its own. It does not see yours coming. It is careless in about one move out of five.

Medium

Looks four moves ahead, far enough to stop a double threat before it is made. In one move out of ten it looks only two moves ahead: it still blocks, but it can walk into a trap.

Hard

Looks eight moves ahead and is never careless. It varies its first few moves a little, so that games do not all begin the same way.

Expert

Plays the opening from a book and then gets one second for every move. In that second it first tries to work the position out exactly, every line to the end of the game. If it finishes, it knows whether the position is won, drawn or lost, and plays accordingly. If it does not finish, it plays the best move a search of the ordinary kind has found, leaving out any move it has already proven to lose.

What Expert guarantees, and what it does not

The book is exact. It holds 10,079 positions from the start of the game, each with a move that was worked out in advance by playing every line to the end. It covers the first seven moves of the side that starts, whatever the other side answers, and the first moves of the side that answers.

Past the book, a move is proven only when the second is long enough. In 49 games against itself, on the computer where it was measured, Expert made 1,474 moves. Of those, 295 came from the book and 1,058 were worked out to the end of the game. The other 121, about one move in twelve, were the best a search could find in the time, with no proof behind them.

It has not lost a game it started. Those 49 games began in the middle lane, with each of the seven replies and each of the seven replies to Expert's next move. The side that started won all 49. Played against itself after each of the seven first moves, Expert also reached the published result every time: a win from the middle lane, a draw from the lanes beside it, and a loss from the four outer lanes.

It can be beaten when it moves second. The game is a win for the side that starts in the middle, so a player who goes first and finds the right move every time beats any opponent, this one included. Expert will make you find all of them.

None of this is a proof that Expert never errs. It is a strong player that has been measured over a limited number of games. On a slow device the second buys less, and fewer of its moves are proven.

The levels against each other

Each level has played the level below it from an empty board, taking turns to go first. A win counts as one point and a draw as half.

  • Easy against Beginner: 88 percent of the points, over 1,000 games.
  • Medium against Easy: 88 percent, over 1,000 games.
  • Hard against Medium: 90 percent, over 1,000 games.
  • Expert against Hard: won all 40 games, the 20 it started and the 20 it did not.

The three lower steps are about equally large. The last one is a wall: Hard does not play without error when it starts, and against Expert one error is enough.

What the hint is

The Hint button is Expert: the book, the exact solver, and one second. The ring it draws is in the place where your piece would stop.

Using it does not make the level you are playing any stronger. Hints are counted, and the count is shown with your record at the bottom of the page.

Sources

The solution of the game is described by John Tromp, who also counted its positions. The exact solver in this engine follows the method Pascal Pons sets out in his tutorial on solving the game, and its results are checked against positions from his published solver.

The other barrels

Checkers is the one where a jump has to be taken, and where a piece that reaches the far row becomes a king, two pieces high.

Backgammon is a race with dice: fifteen pieces a side, and a piece left on its own can be hit and sent back to the start.

Shut the Box is nine numbered tiles and two dice: every roll has to be paid for with tiles that add up to it, and the lower sum left open wins.

Farkle is six dice and a race to 10,000: bank what a turn is worth, or roll again and risk losing all of it.

Yatzy is five dice and a scorecard of thirteen rows: three rolls a turn, and every turn has to be written in a row, even when it is worth nothing there.

Dominoes is twenty-eight tiles and a line that grows at both ends: match a number, draw from the boneyard when nothing fits, and lay your last tile first.

Reversi has one kind of move: put a piece down so that it traps a row of the other color, and the row turns to yours.

Mancala has no dice and nothing hidden: you empty a pit, sow its stones round the board one at a time, and count what ends up in your store.

Chinese Checkers is a race across a star of 121 holes: marbles hop over one another in chains, nothing is ever captured, and the first side to fill the point opposite wins.

Nine Men's Morris is the old game of mills: nine pieces a side, three in a row along a line takes a piece off, and a side left with two pieces or no move has lost.

Tic-Tac-Toe is three in a row on nine squares, and next to it Ultimate tic-tac-toe, where every square holds a small board and each move decides where the next one is played.

Chess is the old game of kings: six kinds of pieces that each move their own way, and a win when the other king is attacked and cannot escape.

Gomoku is five in a row on a board of fifteen lines each way: pieces go where the lines cross, and three in a row with both ends open has to be answered at once.

Ludo is the race with one die: a six brings a piece out of its yard, landing on another color sends that piece back, and the first side with all four pieces home wins.

No games played yet.

Red for the games you won, white for the ones you lost. Your record is kept in this browser and nowhere else.

Start over?