Free Converter

Connect Four Online Game

Play Connect Four online! Drop colored discs and be the first to connect four in a row. Challenge a friend or play against AI.

Red0
0Draw
Yellow0
Player Red's turn

About Connect Four

Connect Four is a two-player game played on a 7-column, 6-row vertical grid. Players take turns dropping colored tokens into columns; tokens stack from the bottom up. The first player to align four tokens horizontally, vertically, or diagonally wins. The game was published commercially by Milton Bradley in 1974 but the underlying rules are older.

Connect Four is solved: with perfect play, the first player wins. The proof was completed in 1988. In practice, most players don't play perfectly, so games are often interesting and competitive. The game is more strategic than Tic-Tac-Toe — the much larger state space (4.5 trillion possible positions) supports deep tactics around forks, threats, and column control.

This implementation offers two-player and single-player against AI. AI difficulty is configurable: random (easy), heuristic-based (medium), and search-based with depth limit (hard). At hard difficulty, the AI plays well but not perfectly — perfect play would require a much deeper search than reasonable in a browser.

Why Play Connect Four

Connect Four scales nicely between casual and serious. Quick games for entertainment, longer thoughtful games for strategy practice. The deeper-than-Tic-Tac-Toe game tree means there's genuine room for strategic improvement over time.

Two-player play is also a solid social game. Easy to learn, hard to master, satisfying to win. Good for relaxed time with friends or family — accessible to children but interesting to adults.

How to Play Connect Four

Drop tokens into columns, get four in a row.

  1. Choose mode: Two-player (alternating turns at the same screen) or single-player (against AI).
  2. First player drops a token: Click a column. The token falls and rests at the bottom (or on top of the existing stack).
  3. Second player drops a token: Click any column. Players alternate placements.
  4. Win or draw: First to align four tokens horizontally, vertically, or diagonally wins. If the board fills with no winner, draw — but in Connect Four with optimal play this is rare.

Common Use Cases

Technical Details

Game state: a 7×6 array tracking each cell's color (red, yellow, or empty). When a player places in a column, the token lands at the lowest empty row in that column. Win check after each move: scan all winning lines (4-in-a-row patterns horizontally, vertically, diagonally).

AI: minimax with alpha-beta pruning, often with iterative deepening (search to depth 2, 4, 6, etc., until time runs out). Transposition tables cache evaluated positions. Position evaluation function counts threats, blocked threats, central control, and tempo.

Game tree: about 4.5 trillion possible positions. Full search is infeasible in browser; depth-limited search (typically 6-9 plies) plays well but not perfectly. Endgame databases enable perfect play but are too large to ship in browser.

Best Practices

Frequently Asked Questions

Who wins with perfect play?
First player. Connect Four was solved in 1988; with perfect play from move one, first player wins regardless of opponent strategy.
How does the AI compare to perfect play?
Hard difficulty plays well but not perfectly; depth-limited search is good enough to challenge most humans but not optimal. Perfect play requires endgame databases too large for browsers.
What's the best opening move?
Center column. The middle column participates in more winning lines than edge columns; controlling it is a strong opening.
Can the AI lose?
Yes. Easy plays randomly. Medium uses simple heuristics. Hard plays a strong but not perfect game. With effort, hard can be beaten by experienced players.
What if the board fills with no winner?
Draw. With perfect play this is unusual; with imperfect play it can happen if both players miss winning opportunities.
Is the game state saved?
Most implementations don't save mid-game. Some track win counts across sessions in localStorage.
Can two people play remotely?
This implementation supports local two-player. Remote play requires a multiplayer server.
How does it differ from Tic-Tac-Toe?
Larger board (7×6 vs 3×3), tokens drop to bottom (gravity), need 4 in a row vs 3. Bigger state space, deeper strategy.