[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6KRDB4ESQ4AVCN9403RR686":3,"skill-same:01M6KRDB4ESQ4AVCN9403RR686":74},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":28,"linkOnly":29,"markdownContent":30,"markdownBody":31,"frontMatter":32,"refName":33,"commitSha":34,"skillDirectory":35,"forksCount":36,"repositoryHtmlUrl":37,"repositoryHomepageUrl":6,"ownerHtmlUrl":38,"ownerBlogUrl":39,"ownerDescription":40,"updatedAt":41,"install":42,"resources":55},"01M6KRDB4ESQ4AVCN9403RR686","procedural-generation",null,"Use when implementing procedural generation — noise-based terrain, BSP dungeons, cellular automata caves, wave function collapse, and seeded randomness in Godot 4.3+","jame581\u002FGodotPrompter","jame581","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F21112138?v=4","01M6KR3KEQ9Z30WVJRR2E2ZVXE","Jan Mesarč","01M6KR3KJVRMPDSMASQPBCBVK3",964,"MIT","https:\u002F\u002Fgithub.com\u002Fjame581\u002FGodotPrompter\u002Fblob\u002Fmaster\u002Fskills\u002Fprocedural-generation\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27],"generation","procedural","procedural generation","use","automata","godot","implementing","godot 4","when","2026-11-10 10:12:30",false,"---\nname: procedural-generation\ndescription: Use when implementing procedural generation — noise-based terrain, BSP dungeons, cellular automata caves, wave function collapse, and seeded randomness in Godot 4.3+\n---\n\n# Procedural Generation in Godot 4.3+\n\nAll examples target Godot 4.3+ with no deprecated APIs. GDScript is shown first, then C#.\n\n> **Related skills:** **2d-essentials** for TileMapLayer usage, **3d-essentials** for 3D terrain meshes, **math-essentials** for vectors and transforms, **godot-optimization** for chunk loading and performance.\n\n---\n\n## 1. Seeded Randomness\n\nAlways use seeds for reproducible generation. This enables shareable seeds, replay, and deterministic testing.\n\n### GDScript\n\n```gdscript\n# RandomNumberGenerator — per-instance, seedable\nvar rng := RandomNumberGenerator.new()\n\nfunc generate_level(level_seed: int) -> void:\n    rng.seed = level_seed\n\n    var width: int = rng.randi_range(20, 40)\n    var height: int = rng.randi_range(15, 30)\n    var enemy_count: int = rng.randi_range(3, 8)\n    var treasure_chance: float = rng.randf_range(0.05, 0.15)\n\n# AVOID: Global randf()\u002Frandi() — one shared generator, randomized at startup\n# and advanced by every other caller, so a sequence is hard to reproduce\n# USE: rng.randf(), rng.randi(), rng.randf_range(), rng.randi_range()\n```\n\n### C#\n\n```csharp\nprivate RandomNumberGenerator _rng = new();\n\npublic void GenerateLevel(ulong levelSeed)\n{\n    _rng.Seed = levelSeed;\n\n    int width = _rng.RandiRange(20, 40);\n    int height = _rng.RandiRange(15, 30);\n    int enemyCount = _rng.RandiRange(3, 8);\n    float treasureChance = _rng.RandfRange(0.05f, 0.15f);\n}\n```\n\n> **Tip:** Generate a seed from a string for shareable level codes: `var level_seed: int = \"MyLevel\".hash()` (C#: `GD.Hash(\"MyLevel\")`)\n\n---\n\n## 2. Noise-Based Generation (FastNoiseLite)\n\n`FastNoiseLite` for height maps, biome distribution, 2D terrain. Key params: `noise_type` (Perlin \u002F Simplex \u002F Cellular \u002F Value), `frequency` (lower = larger features), `seed`. For terrain, sample noise at each tile coord, threshold the value to pick a tile.\n\n> See [references\u002Fnoise-generation.md](references\u002Fnoise-generation.md) for the basic noise-map recipe, noise-type reference table, and 2D terrain + TileMapLayer walkthrough.\n\n---\n\n## 3. BSP Dungeon Generation\n\nBinary Space Partitioning recursively splits a rectangle into smaller rectangles, carves a room inside each leaf, connects siblings with corridors. Produces grid-aligned room-based dungeons (think roguelike).\n\n> See [references\u002Fbsp-dungeons.md](references\u002Fbsp-dungeons.md) for the full recursive partition + room placement + corridor connection algorithm in GDScript + C#.\n\n---\n\n## 4. Cellular Automata (Cave Generation)\n\nFill a grid with random walls\u002Ffloors at ~45% density, then iterate \"a cell becomes a wall if ≥ 5 of 8 neighbors are walls\" 4-5 times. The result is organic cave shapes — no straight corridors.\n\n> See [references\u002Fcellular-automata.md](references\u002Fcellular-automata.md) for the full GDScript + C# implementation with TileMapLayer integration.\n\n---\n\n## 5. Wave Function Collapse (WFC)\n\nWFC is a constraint solver: given a tile set with adjacency rules, pick the lowest-entropy cell, collapse it to a valid tile, propagate constraints, repeat. Produces tile-rule-respecting output but is non-trivial to implement.\n\n> See [references\u002Fwave-function-collapse.md](references\u002Fwave-function-collapse.md) for concept overview and a simplified GDScript + C# implementation.\n\n---\n\n## 6. Common Pitfalls\n\n| Symptom | Cause | Fix |\n|---------|-------|-----|\n| Same level every time | Not seeding the RNG | Set `rng.seed` before generation |\n| Same seed gives a different level | Global `randf()` \u002F `randi()` — randomized at startup and shared with any other code that calls them | Use a dedicated `RandomNumberGenerator` instance |\n| Noise looks blocky | Frequency too high | Lower `frequency` (try 0.01–0.05) |\n| Caves are all wall or all floor | `fill_chance` too extreme or too few iterations | Use fill_chance 0.40–0.50 and 4–6 iterations |\n| BSP rooms overlap | Split position too close to edge | Ensure `min_room_size` buffer in split calculation |\n| WFC contradiction (no valid tile) | Adjacency rules too restrictive | Add more allowed neighbors or implement backtracking |\n| Generation takes too long | Processing entire map in one frame | Use `await get_tree().process_frame` to spread across frames, or use a thread |\n\n---\n\n## 7. Implementation Checklist\n\n- [ ] All generation uses a seedable `RandomNumberGenerator`, never global `randf()`\u002F`randi()`\n- [ ] Seeds are stored with save data so levels can be reproduced\n- [ ] `FastNoiseLite` frequency and octaves are tuned for the game's tile\u002Fworld scale\n- [ ] Large generation is spread across frames or run on a thread to avoid freezing\n- [ ] Generated TileMapLayer content uses terrain autotiling when possible (not hardcoded tile coords)\n- [ ] BSP dungeons verify all rooms are connected before finalizing\n- [ ] Cave generation runs a flood-fill to ensure reachability between key points\n- [ ] Player spawn point is validated to be on a floor tile, not inside a wall\n","# Procedural Generation in Godot 4.3+\n\nAll examples target Godot 4.3+ with no deprecated APIs. GDScript is shown first, then C#.\n\n> **Related skills:** **2d-essentials** for TileMapLayer usage, **3d-essentials** for 3D terrain meshes, **math-essentials** for vectors and transforms, **godot-optimization** for chunk loading and performance.\n\n---\n\n## 1. Seeded Randomness\n\nAlways use seeds for reproducible generation. This enables shareable seeds, replay, and deterministic testing.\n\n### GDScript\n\n```gdscript\n# RandomNumberGenerator — per-instance, seedable\nvar rng := RandomNumberGenerator.new()\n\nfunc generate_level(level_seed: int) -> void:\n    rng.seed = level_seed\n\n    var width: int = rng.randi_range(20, 40)\n    var height: int = rng.randi_range(15, 30)\n    var enemy_count: int = rng.randi_range(3, 8)\n    var treasure_chance: float = rng.randf_range(0.05, 0.15)\n\n# AVOID: Global randf()\u002Frandi() — one shared generator, randomized at startup\n# and advanced by every other caller, so a sequence is hard to reproduce\n# USE: rng.randf(), rng.randi(), rng.randf_range(), rng.randi_range()\n```\n\n### C#\n\n```csharp\nprivate RandomNumberGenerator _rng = new();\n\npublic void GenerateLevel(ulong levelSeed)\n{\n    _rng.Seed = levelSeed;\n\n    int width = _rng.RandiRange(20, 40);\n    int height = _rng.RandiRange(15, 30);\n    int enemyCount = _rng.RandiRange(3, 8);\n    float treasureChance = _rng.RandfRange(0.05f, 0.15f);\n}\n```\n\n> **Tip:** Generate a seed from a string for shareable level codes: `var level_seed: int = \"MyLevel\".hash()` (C#: `GD.Hash(\"MyLevel\")`)\n\n---\n\n## 2. Noise-Based Generation (FastNoiseLite)\n\n`FastNoiseLite` for height maps, biome distribution, 2D terrain. Key params: `noise_type` (Perlin \u002F Simplex \u002F Cellular \u002F Value), `frequency` (lower = larger features), `seed`. For terrain, sample noise at each tile coord, threshold the value to pick a tile.\n\n> See [references\u002Fnoise-generation.md](references\u002Fnoise-generation.md) for the basic noise-map recipe, noise-type reference table, and 2D terrain + TileMapLayer walkthrough.\n\n---\n\n## 3. BSP Dungeon Generation\n\nBinary Space Partitioning recursively splits a rectangle into smaller rectangles, carves a room inside each leaf, connects siblings with corridors. Produces grid-aligned room-based dungeons (think roguelike).\n\n> See [references\u002Fbsp-dungeons.md](references\u002Fbsp-dungeons.md) for the full recursive partition + room placement + corridor connection algorithm in GDScript + C#.\n\n---\n\n## 4. Cellular Automata (Cave Generation)\n\nFill a grid with random walls\u002Ffloors at ~45% density, then iterate \"a cell becomes a wall if ≥ 5 of 8 neighbors are walls\" 4-5 times. The result is organic cave shapes — no straight corridors.\n\n> See [references\u002Fcellular-automata.md](references\u002Fcellular-automata.md) for the full GDScript + C# implementation with TileMapLayer integration.\n\n---\n\n## 5. Wave Function Collapse (WFC)\n\nWFC is a constraint solver: given a tile set with adjacency rules, pick the lowest-entropy cell, collapse it to a valid tile, propagate constraints, repeat. Produces tile-rule-respecting output but is non-trivial to implement.\n\n> See [references\u002Fwave-function-collapse.md](references\u002Fwave-function-collapse.md) for concept overview and a simplified GDScript + C# implementation.\n\n---\n\n## 6. Common Pitfalls\n\n| Symptom | Cause | Fix |\n|---------|-------|-----|\n| Same level every time | Not seeding the RNG | Set `rng.seed` before generation |\n| Same seed gives a different level | Global `randf()` \u002F `randi()` — randomized at startup and shared with any other code that calls them | Use a dedicated `RandomNumberGenerator` instance |\n| Noise looks blocky | Frequency too high | Lower `frequency` (try 0.01–0.05) |\n| Caves are all wall or all floor | `fill_chance` too extreme or too few iterations | Use fill_chance 0.40–0.50 and 4–6 iterations |\n| BSP rooms overlap | Split position too close to edge | Ensure `min_room_size` buffer in split calculation |\n| WFC contradiction (no valid tile) | Adjacency rules too restrictive | Add more allowed neighbors or implement backtracking |\n| Generation takes too long | Processing entire map in one frame | Use `await get_tree().process_frame` to spread across frames, or use a thread |\n\n---\n\n## 7. Implementation Checklist\n\n- [ ] All generation uses a seedable `RandomNumberGenerator`, never global `randf()`\u002F`randi()`\n- [ ] Seeds are stored with save data so levels can be reproduced\n- [ ] `FastNoiseLite` frequency and octaves are tuned for the game's tile\u002Fworld scale\n- [ ] Large generation is spread across frames or run on a thread to avoid freezing\n- [ ] Generated TileMapLayer content uses terrain autotiling when possible (not hardcoded tile coords)\n- [ ] BSP dungeons verify all rooms are connected before finalizing\n- [ ] Cave generation runs a flood-fill to ensure reachability between key points\n- [ ] Player spawn point is validated to be on a floor tile, not inside a wall\n",{"name":5,"description":7},"master","d7b26cdb5fae14d4ef7b713c5bf259395e75c3c6","skills\u002Fprocedural-generation",63,"https:\u002F\u002Fgithub.com\u002Fjame581\u002FGodotPrompter","https:\u002F\u002Fgithub.com\u002Fjame581","https:\u002F\u002Fjanmesarc.online\u002F","Software engineer. My biggest passion is game development.","2026-11-14 20:45:49",{"source":8,"skillName":5,"commands":43,"prompt":53,"zipAvailable":54},[44,47,50],{"tool":45,"command":46},"npx","npx skills add jame581\u002FGodotPrompter --skill procedural-generation",{"tool":48,"command":49},"bunx","bunx skills add jame581\u002FGodotPrompter --skill procedural-generation",{"tool":51,"command":52},"pnpm","pnpm dlx skills add jame581\u002FGodotPrompter --skill procedural-generation","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fjame581\u002FGodotPrompter\u002Fblob\u002Fmaster\u002Fskills\u002Fprocedural-generation\u002FSKILL.md",true,[56,62,66,70],{"path":57,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":60,"sourceHtmlUrl":61},"references\u002Fbsp-dungeons.md","REFERENCE","参考文档",6542,"https:\u002F\u002Fgithub.com\u002Fjame581\u002FGodotPrompter\u002Fblob\u002Fmaster\u002Fskills\u002Fprocedural-generation\u002Freferences\u002Fbsp-dungeons.md",{"path":63,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":64,"sourceHtmlUrl":65},"references\u002Fcellular-automata.md",4655,"https:\u002F\u002Fgithub.com\u002Fjame581\u002FGodotPrompter\u002Fblob\u002Fmaster\u002Fskills\u002Fprocedural-generation\u002Freferences\u002Fcellular-automata.md",{"path":67,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":68,"sourceHtmlUrl":69},"references\u002Fnoise-generation.md",3958,"https:\u002F\u002Fgithub.com\u002Fjame581\u002FGodotPrompter\u002Fblob\u002Fmaster\u002Fskills\u002Fprocedural-generation\u002Freferences\u002Fnoise-generation.md",{"path":71,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":72,"sourceHtmlUrl":73},"references\u002Fwave-function-collapse.md",7506,"https:\u002F\u002Fgithub.com\u002Fjame581\u002FGodotPrompter\u002Fblob\u002Fmaster\u002Fskills\u002Fprocedural-generation\u002Freferences\u002Fwave-function-collapse.md",[75,93,114,144,168,185],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":28},"01M6KRFE5BR2PSD08ZKDAS66R7","xr-development","Use when building VR\u002FAR\u002FXR applications — OpenXR setup, XROrigin3D, hand tracking, controllers, passthrough, and Meta Quest deployment in Godot 4.3+","https:\u002F\u002Fgithub.com\u002Fjame581\u002FGodotPrompter\u002Fblob\u002Fmaster\u002Fskills\u002Fxr-development\u002FSKILL.md",[],[82,83,27,84,24,85,86,87,26,88,89,22,90,91,92],"xr development","development","deployment","vr","setup","tracking","ar","hand","Meta","applications","quest",{"skillNo":94,"name":95,"nameZh":6,"description":96,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":97,"categories":98,"keywords":99,"publishedAt":28},"01M6KRF8GZTG1TAS506MFBSGFC","web-services","Use when a Godot game calls a web server — HTTPRequest, downloads, REST\u002FJSON APIs, auth headers, WebSocketPeer clients, TLS, retries, and keeping secrets out of the build. Not for game networking\u002FRPCs (multiplayer-basics) or browser export (web-export)","https:\u002F\u002Fgithub.com\u002Fjame581\u002FGodotPrompter\u002Fblob\u002Fmaster\u002Fskills\u002Fweb-services\u002FSKILL.md",[],[100,101,102,103,104,105,106,107,22,27,24,108,109,110,111,112,113],"web services","web","services","tls","retries","calling","auth","downloads","clients","headers","secrets","json","build","REST",{"skillNo":115,"name":116,"nameZh":6,"description":117,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":118,"categories":119,"keywords":125,"publishedAt":28},"01M6KRF38Q4WSKAYFS56PG87T0","web-export","Use when shipping a Godot game to the browser — Web export preset options, threads vs no-threads and COOP\u002FCOEP headers, hosting on itch.io or your own server, PWA, JavaScriptBridge, user:\u002F\u002F persistence, audio and input limits, and load size","https:\u002F\u002Fgithub.com\u002Fjame581\u002FGodotPrompter\u002Fblob\u002Fmaster\u002Fskills\u002Fweb-export\u002FSKILL.md",[120],{"categoryNo":121,"categoryName":122,"taxonomyType":123,"taxonomyTypeDesc":124},"01JBSEEDCAT000000000000016","图像与多媒体","SCENARIO","使用场景",[101,126,127,128,129,130,131,132,109,133,134,27,135,136,137,138,139,140,22,141,142,143],"export","web export","threads","limits","shipping","size","options","hosting","input","Coop","preset","browser","game","io","load","pwa","Audio","server",{"skillNo":145,"name":146,"nameZh":6,"description":147,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":148,"categories":149,"keywords":158,"publishedAt":28},"01M6KREYFETEBH62ZTN6EZH2X3","using-godot-prompter","Bootstrap skill — establishes how to find and use GodotPrompter skills, with platform-specific tool mapping","https:\u002F\u002Fgithub.com\u002Fjame581\u002FGodotPrompter\u002Fblob\u002Fmaster\u002Fskills\u002Fusing-godot-prompter\u002FSKILL.md",[150,153],{"categoryNo":151,"categoryName":152,"taxonomyType":123,"taxonomyTypeDesc":124},"01JBSEEDCAT000000000000023","Skill与智能体开发",{"categoryNo":154,"categoryName":155,"taxonomyType":156,"taxonomyTypeDesc":157},"01JBSEEDCAT000000000000032","设计师","PROFESSION","适用职业",[24,159,160,161,162,22,163,164,165,166,167],"using godot prompter","find","with","bootstrap","tool","platform","mapping","how","how to",{"skillNo":169,"name":170,"nameZh":6,"description":171,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":172,"categories":173,"keywords":174,"publishedAt":28},"01M6KRER5G7EQWKGAFN8QJKQ69","tween-animation","Use when implementing tweens — property animation, method tweening, chaining, parallel sequences, easing, and common UI\u002Fgameplay motion recipes","https:\u002F\u002Fgithub.com\u002Fjame581\u002FGodotPrompter\u002Fblob\u002Fmaster\u002Fskills\u002Ftween-animation\u002FSKILL.md",[],[175,176,22,177,178,179,180,181,182,183,25,27,184],"tween animation","Animation","motion","parallel","gameplay","chaining","ui","recipes","common","sequences",{"skillNo":186,"name":187,"nameZh":6,"description":188,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":189,"categories":190,"keywords":191,"publishedAt":28},"01M6KREKGCQMVDV8WX7HWX8BZG","state-machine","Use when building a state machine or refactoring logic into one — enum, node, and resource-based FSM patterns with trade-offs. Not for adding states to an existing one","https:\u002F\u002Fgithub.com\u002Fjame581\u002FGodotPrompter\u002Fblob\u002Fmaster\u002Fskills\u002Fstate-machine\u002FSKILL.md",[],[192,193,194,24,27,195,196,197,198,199,161,22,25,200],"state","state machine","machine","patterns","node","fsm","state machines","trade","trade-offs"]