Bash.tv → GitHub → itch.io

Generate maps, levels, enemies and encounters with code. Seeded randomness (replays, shareable and daily seeds), value noise for terrain and height maps, rooms-and-corridors dungeons, cellular-automata caves, drunkard's-walk paths, Poisson-disc placement for trees, enemies and loot, connectivity checks and keeping the largest region, placing start, exit and items, validating that levels are pla...

Download skill (.zip) Files on GitHub

Procedural generation

Drop-in: assets/procgen.js (tests: same seed gives the same dungeon, daily seed stable within a day, noise smooth and within 0..1, dungeons and caves always connected, walker coverage, Poisson points keep their minimum distance).

import { rng, dailySeed, seedFromString, noise2D, dungeon, caves, walker, regions, isConnected, poissonDisc, toStrings } from "./core/procgen.js";
const seed = new URLSearchParams(location.search).get("seed") ?? dailySeed();     // shareable: ?seed=1234
const r = rng(typeof seed === "string" ? seedFromString(seed) : seed);
const { grid, rooms } = dungeon(60, 40, r, { rooms: 12 });                        // "#" walls, "." floor
const start = rooms[0], exit = rooms.reduce((a, b) => (dist(b, start) > dist(a, start) ? b : a));   // farthest room
const height = noise2D(seed, { octaves: 4, scale: 0.04 });                         // terrain: height(x, y) → 0..1
const trees = poissonDisc(2000, 2000, 60, r, { accept: (x, y) => height(x / 20, y / 20) > 0.45 });

Which generator

Want Use
Dungeon of rooms (roguelike) dungeon (+ loops for alternate paths)
Natural caves caves (cellular automata; keeps the largest region)
Winding paths, organic levels walker
Terrain, biomes, height noise2D thresholds (water < 0.3 < sand < 0.35 < grass < 0.7 < mountain)
Even spacing (trees, enemies, loot) poissonDisc
Runner / platformer Handmade chunks picked by difficulty with rules (endless-runner-development)

Rules for playable results

  1. Seed everything from one rng, so bugs and nice levels can be reproduced and shared. Never Math.random in generation.
  2. Validate every level: connected (isConnected), start can reach exit (pathfinding astar), enough space, items reachable. Regenerate (next seed) if not. Count failures in tests (aim for < 1%).
  3. Place with intent: start and exit far apart, difficulty rising with distance from the start, treasure in dead ends, no enemies near the start.
  4. Handmade + random: designed rooms or chunks stitched randomly give quality and variety.
  5. Generate during a loading moment or a transition, never mid-frame in play (long tasks stutter).
  6. Test with many seeds in node (for (let s = 0; s < 1000; s++) …) and look at a few as text (toStrings(grid)).

Encounters and enemies

Use loot-system weighted tables for “what spawns here” with depth-based minLevel, and wave-spawning budgets for “how much”. Seeded rng keeps runs fair in daily challenges and multiplayer.