FREE AI GAMES
🔍
Loading Game...

Connect 4

Game Overview

The classic Connect Four board game online. Drop colored chips into a 7-column, 6-row grid; first to get four in a row wins. Three AI difficulty levels with real minimax/alpha-beta search.

How to Play

Click (or tap) the column where you want to drop your red chip. The chip falls to the lowest empty spot in that column. Get four of your chips in a row — horizontally, vertically, or diagonally — to win. The AI plays yellow and goes second. Switch the difficulty in the dropdown for Easy (depth-2), Medium (depth-4), or Hard (depth-6) AI.

About Connect 4

Connect Four came out in 1974, published by Milton Bradley, and is one of those games that looks trivial until you actually play someone who knows what they're doing. The rules fit in a sentence: drop a chip into one of seven columns, it falls to the lowest empty spot, first player to get four of their colour in a row (horizontal, vertical, or diagonal) wins. The interesting part is that the game was mathematically solved in 1988 — with perfect play from both sides, the first player always wins by moving in the centre column. The depth comes from the fact that almost nobody plays perfectly.

Our version plays you (red) against an AI opponent (yellow). The AI uses standard minimax search with alpha-beta pruning at three depths:

  • Easy — depth 2 (looks two moves ahead). Will block obvious three-in-a-rows but misses traps and double-threats. Most players beat it consistently.
  • Medium — depth 4. Sees most tactical combinations and sets up forks of its own. About even with a casual player who knows the basics.
  • Hard — depth 6. Sees the entire mid-game accurately. Plays close to optimally. You will need real strategy to beat this consistently.

How to actually play well. Three principles cover 80% of the game. First: play the centre column whenever possible — the centre is part of more potential four-in-a-row lines than any other column. Second: create double threats, where you have two separate three-in-a-row patterns that the opponent can only block one of. Third: count parity — in the long game, odd-numbered rows (1, 3, 5 from the bottom) favour player one, even rows (2, 4, 6) favour player two. Force the win onto a row that's parity-good for you.

Build notes. The minimax function uses standard alpha-beta pruning with move ordering — we try the centre columns first because they're statistically the strongest moves, which lets the search prune more aggressively. The evaluation function scores every 4-window on the board: a 3-in-a-row with an empty cell is worth 15 points, a 2-in-a-row with two empties is 4 points, an opponent's 3-in-a-row gets a -25 penalty (we block aggressively). Even at depth 6 the AI responds in well under a second on every device we've tested, because Connect Four's branching factor is just 7.

Frequently Asked Questions

Is Connect 4 really solved? Can I always win?

It's solved for perfect play — the first player wins by starting in the centre. But our Easy and Medium AI don't play perfectly, so a careful human can absolutely beat them. Hard AI plays close to optimally and is genuinely difficult.

Why does the AI always play yellow?

Because you (red) always go first, which is the natural choice for the human in any 2-player turn-based game. Going first is also a slight strategic advantage, which makes up for the AI seeing several moves ahead.

What's the best opening move?

Centre column. Mathematically the strongest start because the centre is part of more potential winning lines than any other column. The corners are the weakest first moves.

Does the score reset between games?

No — your wins, losses, and draws against the AI accumulate across all your games on this device. The scores save to your browser's local storage and persist until you clear it.

Similar Games to Explore

Embed this Game

Want to feature this game on your own website? Copy the code below: