Play 4 in a Row Online

Drop discs into the grid and be the first to connect four in a row — horizontally, vertically, or diagonally. Challenge the AI or play with a friend.

Created by Brian Hamilton

Game Mode
AI Difficulty
You: 0
vs
AI: 0
Your turn — drop a red disc
How to play 4 in a Row

Drop discs into the columns and get four of your colour in a line.

  • Pick a column; your disc falls to the lowest empty square in it.
  • Four in a row wins — horizontally, vertically or diagonally.
  • Filling a square gives your opponent the square directly above it, so check what that square completes before you play.
  • The game is drawn if the board fills with no line.
  • Easy looks 2 moves ahead, Medium 5, Hard 8. Hard beat Medium in all 40 test games.

Controls: tap or click a column to drop a disc. Choose the AI difficulty, or two-player mode, above the board.

Not sure which column is safe? Use the 4 in a Row calculator — build any position and it will rank all seven columns and warn you which ones hand your opponent the win.

4 in a Row strategy game — drop discs and connect four in a line to win

The square above matters more than the square you are blocking

Every beginner learns to block a line of three. The harder lesson is that filling a square hands your opponent the one above it, and that single fact accounts for most losses that feel unfair.

If your opponent threatens to complete a four, and the square directly above that gap also completes a four for them, blocking does not save you: you fill the lower square and they play on top of it. The position was lost several moves before you noticed.

A block that loses immediately Yellow has three in a row on each of the bottom two rows, so the fifth column completes a line for yellow at two heights. Red blocks the lower one, and yellow plays directly above it to win. The position was already lost before red moved: stacked threats cannot be defended.
Two threats stacked in one column. Blocking the lower one hands over the upper one.
The result from each opening column at the Hard search depth Seven bars, one per opening column, showing who wins when the first move is fixed and the Hard engine then plays both sides. The results are: column 1 second player, column 2 second player, column 3 a draw, column 4 second player, column 5 a draw, column 6 second player, column 7 second player. The first player wins 0 of the seven.
Each opening column, played out by the Hard engine against itself.

Count the parity of your threats

This is the idea that separates good players from careful ones. A threat is only useful if you get to play it, and whether you get to play it depends on how many squares sit beneath it.

Because the board has six rows and players alternate, the squares in a column fall into a pattern: the first player tends to occupy the odd rows counting from the bottom, the second player the even ones. A threat sitting on a row your opponent will reach first is not a threat at all — they will fill it before you can.

The practical version: if you moved first, look for threats on the odd rows; if you moved second, look for the even ones. Building a beautiful line that completes on a square your opponent gets to first is the most common way to lose a game you thought you were winning.

The other half of the same idea: never play a square directly under a square that completes a line for your opponent. If a column is dangerous above, leave the column alone — play elsewhere and make them fill it first.

Start in the centre

The centre column is on more possible four-in-a-rows than any other — it takes part in lines going left, right and both diagonals, while an edge column can only build inward. Openings elsewhere give away that flexibility for nothing.

Connect Four was solved in 1988, independently by Victor Allis and James Dow Allen: with perfect play the first player wins, and the centre opening is the one that keeps that win. Every other opening throws it away.

What is worth knowing is how far “perfect play” is from anything you will meet. Fixing the first move to each column in turn and letting the Hard engine play out both sides, the first player won none of the seven — the second player took five and two were drawn. A theoretical first-move advantage that needs a deeper search than this to appear is not an advantage you can rely on at the board.

What the three difficulty settings actually do

They differ in one thing: how many moves ahead the engine looks. Easy searches two moves and plays at random two times in five; Medium searches five; Hard searches eight. Played head to head, the ordering is not subtle.

40 games per pairing, with the stronger side moving first in half of them.
Matchup Deeper side wins Loses Draws
Hard (8) vs Medium (5) 4000
Medium (5) vs Easy (2) 3910
Hard (8) vs Easy (2) 4000

Three extra moves of lookahead is the difference between winning every game and losing every game. That is the honest shape of this game: it rewards seeing one exchange further ahead far more than it rewards any general principle.

Where players go wrong

Blocking on autopilot. Sometimes the block loses on the spot, as above. Before filling a square, check what completes a line directly above it.

Playing the edges early. Columns 1 and 7 take part in the fewest possible lines. Early moves there give up flexibility for no compensation.

Building one big threat. A single threat gets blocked. Two threats that complete on different squares cannot both be blocked — that, not any one line, is how games are actually won.

Missing the diagonals. Horizontal and vertical lines are easy to see. Almost every surprise loss is a diagonal.

What was verified on this page

Win detection was checked against an independently written scanner — one that sweeps the whole board rather than looking around the last move — on 40,000 positions reached by random legal play. They agree everywhere, as do the lists of playable columns, and dropping then undropping a disc restores the board exactly.

The tactics that must never be wrong were checked at all three depths: across roughly 4,000 positions each, the engine took every immediate win available (589–663 of them per depth) and blocked every stoppable threat (330–359 per depth). The handful it did not block were the stacked kind shown above, where every reply loses — it correctly scored those positions as lost rather than pretending otherwise.

Finally, 201 endgames were solved outright — positions with twelve or fewer empty squares, where win, loss and draw are facts rather than estimates. Given enough depth to see to the end, the engine never once threw away a position that was won.

A game that was solved twice

Connect Four is small enough to be solved completely and large enough that doing so was a real achievement: roughly 4.5 trillion legal positions. Allis and Allen got there within weeks of each other in 1988, by quite different routes — Allis with a knowledge-based approach built on exactly the threat-and-parity rules above, Allen by brute-force search. That both worked says something useful: the human-scale rules are not merely rules of thumb, they encode most of what the search finds.

More games like this

If you like games where seeing one move further decides it, try these:

Best Sokoban Games

Push-box logic puzzles — including our own Cargo Shuffle.