Kaamkoby ICE

Four in a Row

Drop discs into the columns in turn. Four of your discs in a line, across, down or diagonally, wins.

Wins0
Losses0

Red moves first.

Controls

Keyboard
Left and right pick a column, Enter, Space or Down drops a disc. Or press 1 to 7.
Touch
Tap a column to drop a disc into it.

Your best score stays in this browser only. Nothing is sent anywhere. The game pauses when you switch tabs.

About Four in a Row

Four in a Row is a two-player game on an upright grid of seven columns and six rows. Players take turns dropping a disc into a column, and the disc falls to the lowest free space. The first player to line up four discs in a row, across, up and down, or on a diagonal, wins. It is sold in shops under several brand names; the game itself is older and free for anyone to play. This version is written from scratch for Kaamko, with our own board and discs.

You can play the computer at three levels or pass the device to a friend. Your wins and losses against each level of computer are kept in this browser only.

How to play Four in a Row

  1. Red always moves first. Choose Red to start, or Blue to let the other side start.
  2. On your turn, tap or click a column to drop a disc into it. On a keyboard, use Left and Right to pick a column and press Enter, Space or Down to drop, or press a number from 1 to 7.
  3. The disc falls to the lowest empty space in that column. A full column cannot take more discs.
  4. Four of your discs in an unbroken line in any direction wins the game.
  5. If all 42 spaces fill up without a line of four, the game is a draw.

Strategy that works

Play the middle. The centre column is part of more possible lines of four than any other, so discs there do the most work. Mathematicians proved in 1988 that the first player can always win with perfect play, starting in the centre, so moving first is an advantage.

Think about threats rather than single lines. A threat is an empty space that would complete your four. Two threats at once, or two threats stacked one directly above the other, usually win, because your opponent can only block one. Watch for the reverse too: before you drop a disc, check that it does not give your opponent the space right above it. Late in the game, whether a threat sits on an odd or an even row decides who is forced to fill it, which is the deeper part of the game.

How the computer plays

The computer uses minimax search with alpha-beta pruning. It looks ahead a set number of moves, trying centre columns first, and scores positions by the open lines each side can still finish. Easy looks two moves ahead and medium six. Hard searches deeper and deeper, up to ten moves, for about a second per move. Hard is a real test, but it is not a perfect solver and it can be beaten with careful threat play.

Written from scratch by Imperial College of Engineering for Kaamko. No third-party code or art.

Last checked by Imperial College of Engineering. Played through on desktop and a 390px phone screen on this date.