Play Connect Four online against the computer at three levels or a friend on one screen. Drop discs to get four in a row, with undo, hints and sound.
Connect Four takes a minute to learn and much longer to stop losing. Two players take turns dropping discs into a seven-column, six-row grid; each disc falls to the lowest empty slot, and the first to line up four of their colour across, down or diagonally wins. Here you can play the computer at three strengths or pass the screen to a friend, with undo, a hint button and a running score.
The grid has 69 possible lines of four. The computer searches ahead with negamax and alpha-beta pruning: 2 moves on Easy, 4 on Medium and 7 on Hard, trying the middle column first because it belongs to the most lines, which lets the search discard weak branches sooner. When the search runs out of depth it scores the position by counting open lines with three or two of a colour and nothing of the other, plus a small bonus for discs in the centre column. Every level takes a winning move and blocks an immediate threat; Easy also plays a random column about a third of the time. In testing, Hard beat Easy 11 games to 0 and Medium 9 to 2.
A full column ignores clicks. Red always moves first, and the first player has the edge in Connect Four: with perfect play the player who starts in the centre column wins, which is why choosing Yellow against Hard is the tougher game. Hard is strong but not perfect, since a seven-move search cannot see every long trap. Scores last until you close the tab; sounds follow the shared sound settings below the board, where they can be turned down or off.
Opponent
Difficulty
You play
You (Red)
0
Draws
0
Computer (Yellow)
0
Your turn (Red)
When time is up the sound repeats, the tab title flashes and phones vibrate. Click or press any key on the page to stop it. Browsers only allow sound after you have clicked on the page once, so press Test sound if you will leave this tab untouched.