A browser-based strategy game for two players (or one player vs. an AI) played on a triangular grid of nodes.
Open index.html directly in any modern web browser β no build step or server required.
The board is a pyramid of 21 nodes arranged in 6 rows (1 node on top, 6 on the bottom), connected by edges to their neighbours.
Achieve the lowest score at the end of the game. Score is calculated from the nodes you own that are adjacent to the final unclaimed node (the β star node).
- The game lasts 10 rounds.
- Each round both players claim exactly one unclaimed node β Player 1 moves first, then Player 2.
- Every node claimed in the same round is labelled with that round's number (1 β 10).
- The game ends automatically when only one node remains (marked β ).
- Each player sums the round-numbers on their own nodes that directly touch the β node.
- The player with the lower sum wins. (A tie is possible.)
Because later rounds carry higher numbers, claiming high-adjacency nodes early (while round numbers are small) is generally good strategy.
| Mode | Description |
|---|---|
| π€ Two Players | Both players share the same screen and take turns clicking nodes. |
| π€ vs AI | Play against a computer opponent. Choose whether you go first (π΅) or second (π΄). |
The AI uses a two-phase approach:
- Early game (> 10 unclaimed nodes): A greedy heuristic β prefers nodes with the most unclaimed neighbours so that high-adjacency (high-risk) nodes are claimed while round numbers are still small.
- Late game (β€ 10 unclaimed nodes): Full minimax search with alpha-beta pruning, guaranteeing optimal play for the rest of the game.
Number_pyramid/
βββ index.html # Complete game (HTML + CSS + JavaScript β single file, no dependencies)
βββ README.md
# Clone the repository
git clone https://github.com/tackandr/Number_pyramid.git
# Open the game
open Number_pyramid/index.html # macOS
xdg-open Number_pyramid/index.html # Linux
start Number_pyramid/index.html # WindowsOr simply double-click index.html in your file manager.
Works in any modern browser that supports SVG and ES6+ JavaScript (Chrome, Firefox, Edge, Safari).
This project is open source. See the repository for details.