npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

deterministic-map

v1.0.4

Published

A deterministic map generator using cryptographic hashes for reproducible game maps

Readme

Deterministic Map Generator

https://cryptohunter.fun

A deterministic map generation system that creates game maps based on cryptographic hashes. This system uses a random hash to generate consistent, reproducible maps for games.

Features

  • Deterministic Generation: Same input always produces the same output
  • Cryptographic Entropy: Uses SHA-256 hashing for unpredictable but reproducible randomness
  • Modular Design: Separate classes for dice, land generation, and player positioning
  • Extensible: Easy to add new land types and generation rules

Project Structure

deterministic-map/
├── src/
│   ├── index.js                    # Main exports
│   ├── dice.js                     # DeterministicDice class
│   ├── gameLandGenerator.js        # GameLandGenerator class
│   └── playerPositionGenerator.js  # PlayerPositionGenerator class
├── example/
│   └── generateMap.js              # Example usage script
├── random_sample.txt               # Sample random hash
├── package.json                    # Project dependencies
└── README.md                       # This file

Classes

DeterministicDice

Generates deterministic random numbers based on a cryptographic hash.

  • Constructor: Takes a random hash as entropy source
  • roll(count): Generates random numbers using hex characters
  • rehashEntropy(): Extends entropy by hashing when needed

GameLandGenerator

Generates game maps with different land types.

  • generateLand(): Creates a grid of land tiles
  • placeTreasure(): Places treasure locations (1 + map size / 12)
  • saveMapToFile(): Saves map data to JSON file
  • printMapSummary(): Displays land type statistics

PlayerPositionGenerator

Generates deterministic starting positions for players.

  • generateStartingPosition(): Creates position for single player
  • generateAllPlayerPositions(): Creates positions for multiple players

Usage

Basic Example

import { DeterministicDice, GameLandGenerator } from "./src/index.js";

// Create dice with random hash
const dice = new DeterministicDice("0x1234567890abcdef...");

// Generate 20x20 map
const generator = new GameLandGenerator(dice, 20);
generator.generateLand();
generator.placeTreasure();
generator.saveMapToFile("my_map.txt");

Command Line Usage

# Generate map for game ID "sample"
node example/generateMap.js sample

# Or with explicit parameter
node example/generateMap.js --gameId=sample

This requires a file named random_sample.txt containing the random hash.

Land Types

  • Type 1: Common land (probability: 11/16)
  • Type 2: Uncommon land (probability: 4/16)
  • Type 3: Rare land (probability: 1/16)
  • Type X: Treasure

Installation

npm install

Dependencies

  • Node.js (ES modules support)
  • Built-in crypto module for hashing
  • Built-in fs module for file operations

Testing

Use the provided random_sample.txt file to test the system:

node example/generateMap.js sample

This will generate a map_sample.txt file with the deterministic map data.