HEX — Nash's Game
Minimax · Alpha-Beta Pruning · Union-Find · Dijkstra
Game Mode
Choose Your Side
🎯
Objective
Form an unbroken chain of your pieces connecting your two assigned edges. No draws exist — someone always wins (John Nash, 1942).
Teal — Left → Right
Connect the Left edge to the Right edge. Choose this side in vs AI mode using the Side Selector above.
Gold — Top → Bottom
Connect the Top edge to the Bottom edge. In 2-Player mode pass the device to Player 2 on their turn.
👆
How to Place
Tap or click any empty hexagon to place your piece. Players alternate turns automatically. Each hex touches 6 neighbours.
🧠
Strategy Tips
Control the centre — it connects the most paths. Block your opponent's chain early. Every move both attacks and defends. Use Undo to take back a move.
👥
2-Player Mode
Both players share one device. Screen shows whose turn it is clearly. Player 1 = Teal (Left→Right). Player 2 = Gold (Top→Bottom).
MM
Minimax Search
Shannon (1950) — Philosophical Magazine
AI explores all possible moves to a fixed depth, alternating between maximising its own score and minimising yours. Guarantees the best possible move. Complexity: O(b^d).
α-β
Alpha-Beta Pruning
Knuth & Moore (1975) — Artificial Intelligence Journal
Cuts branches that cannot affect the final result. α = best MAX found; β = best MIN found. Prune when β ≤ α. Reduces complexity from O(b^d) to O(b^(d/2)) — searches twice as deep in the same time.
UF
Union-Find (Win Detection)
Tarjan (1975) — Journal of the ACM
Detects winning connections in O(α(n)) ≈ O(1) amortized time using Disjoint Sets. Two virtual edge-nodes per player — a win is detected the instant they merge into the same component.
DJ
Dijkstra Heuristic
Dijkstra (1959) — Numerische Mathematik
Board evaluation inside Minimax. Computes minimum "cost" path to win (friendly=0, empty=1, enemy=∞). Score = player cost − AI cost, giving the AI a sense of who is closer to winning.
Board
AI
Tap a hex to begin
⬡ Gold — Top → Bottom
Teal ←→
Teal ←→
⬡ Gold — Top → Bottom
You (Teal) — Left → Right
AI (Gold) — Top → Bottom
Tap any hex to place your piece
AI Brain — Live
Thinking…
AlgorithmMinimax + α-β
Search Depth
Nodes Evaluated
Branches Pruned
Board Score
AI Last Move
MOVE
TOTAL NODES
DEPTH
Move History
No moves yet.