Skip to content

tackandr/Number_pyramid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”Ί Number Pyramid

A browser-based strategy game for two players (or one player vs. an AI) played on a triangular grid of nodes.

Live Demo

Open index.html directly in any modern web browser β€” no build step or server required.

Gameplay

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.

Objective

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).

Rules

  1. The game lasts 10 rounds.
  2. Each round both players claim exactly one unclaimed node β€” Player 1 moves first, then Player 2.
  3. Every node claimed in the same round is labelled with that round's number (1 – 10).
  4. The game ends automatically when only one node remains (marked β˜…).
  5. Each player sums the round-numbers on their own nodes that directly touch the β˜… node.
  6. 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.

Game Modes

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 (πŸ”΄).

AI Strategy

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.

Project Structure

Number_pyramid/
β”œβ”€β”€ index.html   # Complete game (HTML + CSS + JavaScript β€” single file, no dependencies)
└── README.md

Running Locally

# 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  # Windows

Or simply double-click index.html in your file manager.

Browser Compatibility

Works in any modern browser that supports SVG and ES6+ JavaScript (Chrome, Firefox, Edge, Safari).

License

This project is open source. See the repository for details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages