npx claudepluginhub fcsouza/agent-skills --plugin standalone-skillsThis skill uses the workspace's default tool permissions.
Procedural content generation for replayability — maps, dungeons, loot, terrain, NPC behavior variation, and world construction. Genre-agnostic — applies to roguelikes, survival games, idle games, open-world titles, or any game that benefits from generated content.
Delivers procedural content generation expertise with noise functions, Wave Function Collapse, L-systems, Markov chains, and validation for roguelikes, terrains, dungeons, infinite worlds.
Implements procedural generation in Godot 4.3+ with GDScript and C# examples for seeded randomness, FastNoiseLite terrain, BSP dungeons, cellular automata caves, and wave function collapse.
Level design fundamentals, pacing, difficulty progression, environmental storytelling, and spatial design for engaging gameplay experiences.
Share bugs, ideas, or general feedback.
Procedural content generation for replayability — maps, dungeons, loot, terrain, NPC behavior variation, and world construction. Genre-agnostic — applies to roguelikes, survival games, idle games, open-world titles, or any game that benefits from generated content.
Trigger: procedural generation, dungeon gen, map gen, loot table, world seed, noise terrain, BSP, wave function collapse, randomization, seeded random, perlin noise, simplex noise, generated content, roguelike, replayability
game-economy-design — loot balance and reward curvespostgres-game-schema — caching generated content, seed storageWill Wright: "I'm not interested in creating a game that does things for the player. I want to create a simulation that responds to the player." — Emergence from simple rules is the heart of procedural generation.
Derek Yu (Spelunky): "The magic of procedural generation isn't randomness — it's constrained randomness. The constraints are the design."
Tarn Adams (Dwarf Fortress): "Simulate the world first, then let the stories emerge."
The original Rogue developers (Michael Toy, Glenn Wichman): "Every run should feel different, but every run should feel fair."
game-economy-design)Math.random(); JS engine differences in Math.random() break cross-platform seedsChoose a seeded PRNG. Never use Math.random() — it is not seedable and varies across engines.
// mulberry32 — fast, deterministic, 32-bit state
const mulberry32 = (seed: number): (() => number) => {
let s = seed | 0;
return () => {
s = (s + 0x6d2b79f5) | 0;
let t = Math.imul(s ^ (s >>> 15), 1 | s);
t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
};
};
Derive per-system seeds from a world seed:
const deriveSubSeed = (worldSeed: string, system: string, id: string): number => {
const str = `${worldSeed}:${system}:${id}`;
let hash = 0;
for (let i = 0; i < str.length; i++) {
hash = (Math.imul(31, hash) + str.charCodeAt(i)) | 0;
}
return hash >>> 0;
};
| Content Type | Algorithm | When to Use |
|---|---|---|
| Dungeon rooms/corridors | BSP tree | Grid-based levels with rooms and hallways |
| Open terrain, height maps | Perlin/Simplex noise | Continuous, smooth landscapes |
| Tile-based worlds | Wave Function Collapse | Tile sets with adjacency rules |
| Loot, drops, rewards | Weighted random tables | Any item distribution system |
| Cave systems | Cellular automata | Organic, cave-like shapes |
| City layouts, road networks | L-systems / Voronoi | Structured but organic layouts |
Before any generation runs, define hard limits:
interface GenerationBudget {
minRooms: number;
maxRooms: number;
minEnemies: number;
maxEnemies: number;
minItems: number;
maxItems: number;
maxRetries: number; // CRITICAL: prevent infinite loops
}
const generateWithValidation = <T>(
generator: (rng: () => number) => T,
validator: (result: T) => boolean,
seed: number,
maxRetries: number,
): T | null => {
for (let attempt = 0; attempt < maxRetries; attempt++) {
const rng = mulberry32(seed + attempt);
const result = generator(rng);
if (validator(result)) return result;
}
return null; // Budget exhausted — loosen constraints or fix generator
};
For expensive generation (full dungeon layouts, world maps), cache keyed by seed:
// Store in DB via postgres-game-schema
const cacheKey = `${generatorVersion}:${seed}`;
// Regenerate on demand for cheap content (loot rolls, NPC names)
Cross-reference redis-game-patterns for ephemeral seed caches during active sessions.
See boilerplate/dungeon-generator.ts for a complete BSP-based dungeon generator. Usage:
import { DungeonGenerator } from './dungeon-generator';
const generator = new DungeonGenerator();
const dungeon = generator.generate('my-seed-123', {
width: 80,
height: 60,
minRooms: 5,
maxRooms: 12,
minRoomSize: 4,
maxRoomSize: 10,
corridorWidth: 1,
});
// dungeon.rooms — array of placed rooms
// dungeon.corridors — connections between rooms
// dungeon.entrance — starting point
// dungeon.exits — exit points
// dungeon.grid — 2D cell array for rendering
See boilerplate/loot-table.ts for a weighted loot table using Vose's alias method. Usage:
import { LootTable } from './loot-table';
const table = new LootTable<string>()
.add('Common Sword', 60)
.add('Rare Shield', 25)
.add('Epic Staff', 10)
.add('Legendary Crown', 4)
.add('Mythic Amulet', 1)
.withGuaranteed('Health Potion');
const drops = table.roll(3, seededRng); // 3 weighted rolls + guaranteed item
game-economy-design — loot balance, reward curves, drop rate tuningpostgres-game-schema — caching generated content in DB, seed storageredis-game-patterns — ephemeral seed cache, session-scoped generated contentgame-backend-architecture — server-side generation, authoritative dungeon statemaxRetries and fail gracefullyMath.random() implementations differ between V8, SpiderMonkey, and JavaScriptCore; always use an explicit PRNGWill Wright (SimCity, Spore): The best procedural systems are emergent — simple rules interacting to produce complex, unpredictable results. Your generator should surprise you. If you can predict every output, the system isn't complex enough. If every output is chaos, the constraints aren't tight enough.
Derek Yu (Spelunky): Procedural generation is not a substitute for design. Every generated room, every placed enemy, every dropped item should feel intentional. The generator is a tool that executes your design intent at scale — it needs clear rules, tight constraints, and careful tuning.
Tarn Adams (Dwarf Fortress): Simulate deeply. The richest procedural content comes from layered simulation — history generates factions, factions generate conflicts, conflicts generate quests. Each layer feeds the next.