Budi GamesQuiet puzzles, one at a time
Two-player strategy · or one against the machine

Connect Four

Seven columns, six rows, gravity, and one rule: four of your colour in a line wins. Play a friend across the same screen or take on three strengths of computer opponent, from one that reads two moves ahead to one that reads six.

0Red wins
0Yellow wins
0Draws

Pick a column to drop your first disc.

Keyboard: 1 to 7 drops in that column. Mouse or touch: use the buttons above the grid, or tap the column itself.

How to play

Players take turns dropping a disc into one of the seven columns. A disc always falls to the lowest free slot in that column, so you choose the column and gravity chooses the row — that constraint is the entire game. The first player to line up four of their own discs horizontally, vertically or diagonally wins, and the four in question are outlined on the board when it happens. Fill all forty-two slots without a line and the game is a draw.

The Opponent row picks who you are up against. Two players passes the same board back and forth between red and yellow on one device. The other three are computer opponents, and in all of them you are red and the machine is yellow. Pressing New game alternates who opens, so half the time you will arrive at a board where yellow has already moved; the opening advantage does not quietly stay with one side all evening.

The three counters above the board are a running tally of red wins, yellow wins and draws. They are stored in your browser and they persist across games, opponents and visits until you clear your site data.

Controls

  • Number keys 17 drop a disc into that column, which is by far the fastest way to play.
  • Mouse or touch — press one of the numbered buttons above the grid, or simply tap anywhere in the column you want. A column that is already full is disabled and says so to a screen reader.
  • Undo takes back a complete round against the computer: your disc and the reply it produced, returning you to the position you were actually staring at. In two-player mode it takes back one disc. If the game had already finished, undoing also removes the point that was just added to the tally, so replaying a lost ending does not quietly inflate the score.
  • New game clears the board and swaps the opening move to the other colour.

What the three computers are actually doing

All three opponents run the same search. The machine plays out every legal reply, and every reply to those replies, down to a fixed number of plies, then scores the resulting positions and assumes both sides pick their best line. Positions are scored by looking at all sixty-nine groups of four adjacent slots on the board: a group holding three of your discs and one empty slot is a live threat and worth a great deal, a group with two is worth a little, and a group containing discs of both colours is dead and worth nothing at all because neither side can ever complete it. There is also a small bonus for discs in the middle column, which belongs to more of those groups than any other.

What separates the levels is depth. Casual reads two plies — your move and its own reply — and then, among the moves it rates as roughly equal, it picks one at random rather than always choosing the same column. That randomness is what makes it feel like an opponent instead of a table. Sharp reads four plies, which is enough to set a trap one round in advance. Ruthless reads six and will punish almost any loose disc within two moves.

One thing is deliberately not left to the search: before any level thinks at all, it checks whether it can complete a four right now, and whether you can complete one on your next turn. It takes the win, and failing that it blocks. Casual is meant to be beatable, not blind, and there are few things more irritating than an easy setting that overlooks a four you have had sitting on the board for two turns.

Threats, and the parity that decides who gets them

Winning Connect Four is not about making a line. It is about making two lines at once, because a single threat is simply blocked. The position you are aiming for is one where you have two empty slots that would each complete a four, in different columns; your opponent can only fill one per turn.

The most productive shape for that is three of your discs in a row along a line with both ends open, the classic split where the fourth disc can go on either side. The second most productive is a diagonal threat sitting directly above a slot your opponent is being forced to fill. Which brings us to the part that separates good players from strong ones: which row a threat lives on matters.

Because discs stack, the only way to reach a high slot is for someone to fill the slot beneath it. Count the rows from the bottom. On a seven-by-six board where red moves first, red tends to profit from threats on the odd rows — the first, third and fifth — while yellow profits from threats on the even ones. The reason is a counting argument rather than a mystery: as columns fill in turn, the parity of the row you need decides which of you is forced to play the disc directly beneath it. This is why experienced players sometimes decline an obvious-looking stack: putting your disc under your opponent's winning square is a gift, and refusing to be the one who fills that slot is often worth more than any attack you could launch instead.

Two practical habits follow. Take the centre column early, because it participates in more possible fours than any other and the computer will take it if you do not. And before every drop, look at the slot your disc creates directly above itself and ask what your opponent would do with it. Most losses at Sharp and Ruthless are handed over that way rather than out-thought.

Results from our own play testing, and nothing more than estimates: a player who knows the double-threat idea beats Casual most of the time, splits with Sharp somewhere around evenly, and wins perhaps one game in five against Ruthless when moving first. A full game runs about twenty to thirty discs, so two to five minutes at a relaxed pace. Ruthless takes a noticeable moment to reply on a crowded board, because six plies of search is real work.

Where the game came from

The vertical four-in-a-row game was sold by Milton Bradley in 1974 under the name Connect Four, and the upright plastic frame with the sliding base is the version almost everyone pictures. Line games of this family are far older, but the gravity rule is what turned a simple race into a strategy game with a literature.

It also has an ending. In 1988 the game was solved independently by James Dow Allen and by Victor Allis, whose work on it became a well-known master's thesis: on the standard seven-by-six board, with perfect play from both sides, the first player wins by opening in the centre column, and opening anywhere else lets the second player at least draw. That result does nothing to spoil a real game — no human plays perfectly, and the computer on this page reads six moves ahead at most, not forty-two. The board and the opponents here are our own implementation, written for this site.

Questions players ask

Will Casual ever miss an obvious win?

No. Every level checks for a four it can complete immediately, then for one it has to block, before it starts searching. Casual is weak because it plans badly, not because it cannot see.

Can two people share one device?

Yes — choose Two players and the board simply alternates between red and yellow, with no computer involved and no thinking pause.

Why does the computer sometimes move first?

New game swaps the opening colour each time. Since moving first is a real advantage in Connect Four, alternating keeps a long session honest.

Is the score kept anywhere except my browser?

No. Wins, draws, your chosen opponent and whose turn it is to start are stored locally under keys beginning with bg:, and clearing site data resets them.

Keep going

  • Lights Out — another grid where every move changes more than the square you touched.
  • Tower of Hanoi and recursion — what a search tree looks like from the inside.
  • Crate Push — planning several moves ahead, with nobody playing against you.