Connect Four
Play against a Minimax AI with alpha-beta pruning
Free Online Connect Four Game
Play Connect Four online for free against a computer opponent. You play as red and move first, while the AI plays yellow using a depth-4 Minimax search with alpha-beta pruning and heuristic board scoring. Control the center, block threats, and connect four discs horizontally, vertically, or diagonally before the AI.
How to Play Connect Four
- Choose a column to drop your red disc; gravity places it in the lowest empty slot.
- Connect four discs horizontally, vertically, or diagonally to win.
- Block the AI's three-in-a-row threats and build your own winning lines.
- Use central columns strategically to create more possible connections.
- If all 42 spaces fill without a winner, the game is a draw.
Connect Four Game Features
- Standard 7-column × 6-row board.
- Depth-4 Minimax AI with alpha-beta pruning.
- Center control and four-cell window heuristic scoring.
- Center-first move ordering for more efficient search.
- Animated disc drops and glowing winning discs.
- Mouse, touch, and keyboard controls.
- Undo, sound effects, dark mode, and session scoreboard.
- Responsive desktop, tablet, and mobile design.
Frequently Asked Questions
What are the rules of Connect Four?
Players take turns dropping discs into seven columns. The first player to connect four horizontally, vertically, or diagonally wins. A full board with no winner is a draw.
Who plays first?
You play first as the red player. The computer is yellow and responds after your move.
How does the Connect Four AI work?
The computer uses Minimax with alpha-beta pruning at depth 4. It scores positions using center control and four-cell windows, with very large values for terminal wins and losses.
Can I play on a phone?
Yes. The board is responsive and supports touch-friendly column selection. Physical keyboards can use keys 1–7.
Can I undo a move?
Yes. Undo restores the position before your most recent turn. It is available before the game ends.
Is this game free?
Yes. It runs directly in the browser with vanilla HTML, CSS, and JavaScript and requires no external game library.
0 Comments