DevTools Logo

Connect Four

Connect Four

Classic 7×6 Connect Four — play a friend or a tunable minimax engine

Runs in your browser

Connect Four

You to play

Click a column, or focus the board and use ← / → then Enter to drop. Esc opens the new-game prompt.

Amber ● discs have a solid centre; blue ▬ discs are striped, so both players stay distinguishable without relying on colour. A win highlights all four discs.

Game details

0 discs played
Nodes this move
0
0 nodes/s · depth 0
Search time
0 ms
up to depth 4 per move

Move history

No moves yet. Click a column or use the arrow keys.

Scores

Depth 4WinsLossesDraws
You vs AI000

Depth is the maximum lookahead. Node counts update after each completed depth; the engine checks immediate wins, blocks and centre control before searching deeper.

New game. You move first.

Examples

Play the computer

Choose vs Computer and depth 4, click a column and watch the node counter climb between search depths before the AI replies.

Hot-seat match

Switch to Two players, take turns dropping discs and use Undo if you want to retry a single move.

Study the engine

Compare the search log at depth 1 and depth 8: deeper moves inspect more nodes and prefer wins that arrive sooner.

About this game

Drop discs into a 7×6 grid and connect four horizontally, vertically or diagonally. Play hot-seat with a friend, or face a deterministic minimax engine whose depth you can tune from 1 to 8.

The computer checks for an immediate win, blocks an immediate threat, then searches with alpha-beta pruning, center-out move ordering and a transposition table. Each completed search depth updates the live node counter and nodes-per-second readout, so you can watch the engine think rather than waiting on an opaque move. Deeper presets see more plies but take longer; a wall-clock budget keeps even depth 8 responsive. The per-move log records the column, depth, nodes and milliseconds for every computer reply.

Undo steps back one move in hot-seat mode or a full player/computer pair against the AI. Winning lines are highlighted, full columns shake instead of accepting a disc, and a full board with no four-in-a-row is a draw. Scores are tallied per depth in computer mode and per player in hot-seat mode, and are stored only in this browser.

The board is fully keyboard playable: focus it, move the selected column with the left and right arrow keys, press Enter to drop and Escape to start a new game. Amber solid-centre discs and blue striped discs remain distinguishable without relying on colour, and reduced-motion preferences disable the drop animation.

What this game does not do

  • Processes only the inputs provided in this session without connecting to external accounts or background servers.
  • Runs entirely in the current browser tab; nothing is synced across devices or backed up to a server.

How to use this game

  1. Select opponent and AI depth

    Choose AI difficulty (search depth) or two-player pass-and-play.

  2. Drop discs into columns

    Click or use number keys 1–7 to drop discs and race to connect four.

  3. Inspect search stats or undo

    View evaluated nodes/scores per AI turn or undo moves to explore lines.

Use cases

Play the computer

Choose vs Computer and depth 4, click a column and watch the node counter climb between search depths before the AI replies.

Hot-seat match

Switch to Two players, take turns dropping discs and use Undo if you want to retry a single move.

Study the engine

Compare the search log at depth 1 and depth 8: deeper moves inspect more nodes and prefer wins that arrive sooner.

Common mistakes

Mistake:What does search depth change?

Fix:Higher depth lets the minimax solver look more plies ahead to spot forced traps and double threats, trading a few extra milliseconds of browser compute for stronger play.

Mistake:Can two people play locally on the same screen?

Fix:Yes. Switch between Player vs AI and local two-player pass-and-play mode, with full move undo and win-line highlighting.

Frequently asked questions

How does the Connect Four AI choose moves?

It runs deterministic minimax search with alpha-beta pruning, center-column move ordering, and 4-in-a-row window heuristics—no cloud calls or neural networks.

What does search depth change?

Higher depth lets the minimax solver look more plies ahead to spot forced traps and double threats, trading a few extra milliseconds of browser compute for stronger play.

Can two people play locally on the same screen?

Yes. Switch between Player vs AI and local two-player pass-and-play mode, with full move undo and win-line highlighting.

Are game stats uploaded anywhere?

No. Match state and win counters live locally in your browser.