Connect Four
The classic drop-and-connect strategy game against an AI opponent on canvas. The...
Connect Four
📖 How to Play
Click a column, or press 1-7, to drop a disc. Connect four horizontally, vertically or diagonally to win; filling the board without a winner is a draw. Undo takes back a move. Play threats rather than potential — a double threat beats the AI's search depth.
📚 Complete Game Guide
Connect Four
Connect Four is the classic two-column drop-and-connect strategy game, played against an AI opponent on an HTML5 canvas. Drop a disc into one of seven columns; it falls to the lowest free row; the first player to line up four of their discs — horizontally, vertically or diagonally — wins.
The opponent is minimax with alpha-beta pruning over the 7×6 board. Its evaluation function is hard-coded and weighs centre-column control, immediate threats and blocking moves, so it plays a strong game without opening deliberately. It will not always pick the theoretically best move.
How to Play
- Click a column (or use the number keys) to drop your disc.
- Watch the AI think — it replies in under a second at normal depth.
- Connect four to win. Fill the board with no winner and it is a draw.
- Use Undo to take back a move, or New game to restart.
Controls
- Click a column — drop a disc there
- 1 – 7 — drop into the matching column from the keyboard
- Undo — take back the last move
- New game — restart
- Reset — clear the board and the win indicator
Tips
- The centre column is worth more than any other because every line that runs through it also runs through more winning combinations. If the AI gives you a free turn there, take it.
- Play threats, not potential. A disc that completes four wins; a disc that completes three and has an open end on both sides forces the AI to answer and loses you nothing.
- Set up two simultaneous threats and the AI cannot block both. Double threats beat search depth.
- Undo is unlimited. If you are analysing rather than playing, use it freely.
Save Data
Nothing is persisted. A page reload starts a new game.
Open Source & License
Connect Four (c4) was created by Kenrick and is licensed under the
MIT License.
- Original game source: https://github.com/kenrick95/c4
- Original live build: https://kenrick95.github.io/c4/
This integration self-hosts that build so it runs entirely in your browser. It was compiled from the upstream monorepo with the upstream toolchain; the only build flag changed was making Vite emit a relative asset base so the game works from its embedded path. The optional online-play server component is not included, since this build is single-player against the AI.
🎮 Controls
Share This Game
🎮 Related Games
Swap
A turn-based grid puzzler with a roguelike twist. Every tile you step on swaps with an adjacent one, so the floor rearranges under you as you plan against an AI that sees several moves ahead.
Command & Conquer HTML5
A real-time strategy game in the browser: build a base, harvest ore, train tanks and fight off incoming waves.
Mindustry Classic
The classic build of Mindustry — an open-source factory-building tower-defense game. Mine resources, build conveyor belts, craft ammo, and defend your core from endless waves of enemies. Pure browser version based on build 40.
Hextris
Tetris on a hexagonal grid. Rotate and stack falling hexes, line up three of the same colour to clear them, and survive as the waves get faster. Plain JavaScript, no build step.
💬 Comments
Coming soon! Sign in to leave a comment.