본문으로 건너뛰기
cccskills
무료GitHub에 공개

procedural-generation

Use when implementing procedural generation — noise-based terrain, BSP dungeons, cellular automata caves, wave function collapse, and seeded randomness in Godot 4.3+

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(5)

  • SKILL.md4.9 KB
  • references/bsp-dungeons.md6.4 KB
  • references/cellular-automata.md4.5 KB
  • references/noise-generation.md3.9 KB
  • references/wave-function-collapse.md7.2 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Procedural Generation in Godot 4.3+

All examples target Godot 4.3+ with no deprecated APIs. GDScript is shown first, then C#.

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.


1. Seeded Randomness

Always use seeds for reproducible generation. This enables shareable seeds, replay, and deterministic testing.

GDScript

# RandomNumberGenerator — per-instance, seedable
var rng := RandomNumberGenerator.new()

func generate_level(level_seed: int) -> void:
    rng.seed = level_seed

    var width: int = rng.randi_range(20, 40)
    var height: int = rng.randi_range(15, 30)
    var enemy_count: int = rng.randi_range(3, 8)
    var treasure_chance: float = rng.randf_range(0.05, 0.15)

# AVOID: Global randf()/randi() — not reproducible across calls
# USE: rng.randf(), rng.randi(), rng.randf_range(), rng.randi_range()

C#

private RandomNumberGenerator _rng = new();

public void GenerateLevel(ulong levelSeed)
{
    _rng.Seed = levelSeed;

    int width = _rng.RandiRange(20, 40);
    int height = _rng.RandiRange(15, 30);
    int enemyCount = _rng.RandiRange(3, 8);
    float treasureChance = _rng.RandfRange(0.05f, 0.15f);
}

Tip: Generate a seed from a string for shareable level codes: var seed: int = "MyLevel".hash()


2. Noise-Based Generation (FastNoiseLite)

FastNoiseLite for height maps, biome distribution, 2D terrain. Key params: noise_type (Perlin / Simplex / Cellular / Value), frequency (lower = larger features), seed. For terrain, sample noise at each tile coord, threshold the value to pick a tile.

See references/noise-generation.md for the basic noise-map recipe, noise-type reference table, and 2D terrain + TileMapLayer walkthrough.


3. BSP Dungeon Generation

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

See references/bsp-dungeons.md for the full recursive partition + room placement + corridor connection algorithm in GDScript + C#.


4. Cellular Automata (Cave Generation)

Fill a grid with random walls/floors 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.

See references/cellular-automata.md for the full GDScript + C# implementation with TileMapLayer integration.


5. Wave Function Collapse (WFC)

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

See references/wave-function-collapse.md for concept overview and a simplified GDScript + C# implementation.


6. Common Pitfalls

SymptomCauseFix
Same level every timeNot seeding the RNGSet rng.seed before generation
Different results on different platformsUsing global randf() / randi()Use a dedicated RandomNumberGenerator instance
Noise looks blockyFrequency too highLower frequency (try 0.01–0.05)
Caves are all wall or all floorfill_chance too extreme or too few iterationsUse fill_chance 0.40–0.50 and 4–6 iterations
BSP rooms overlapSplit position too close to edgeEnsure min_room_size buffer in split calculation
WFC contradiction (no valid tile)Adjacency rules too restrictiveAdd more allowed neighbors or implement backtracking
Generation takes too longProcessing entire map in one frameUse await get_tree().process_frame to spread across frames, or use a thread

7. Implementation Checklist

  • All generation uses a seedable RandomNumberGenerator, never global randf()/randi()
  • Seeds are stored with save data so levels can be reproduced
  • FastNoiseLite frequency and octaves are tuned for the game's tile/world scale
  • Large generation is spread across frames or run on a thread to avoid freezing
  • Generated TileMapLayer content uses terrain autotiling when possible (not hardcoded tile coords)
  • BSP dungeons verify all rooms are connected before finalizing
  • Cave generation runs a flood-fill to ensure reachability between key points
  • Player spawn point is validated to be on a floor tile, not inside a wall

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Use when working with 2D-specific systems — TileMaps, parallax scrolling, 2D lights and shadows, canvas layers, particles 2D, custom drawing, and 2D meshes in Godot 4.3+

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

jame581/GodotPrompter8542026년 10월 15일 업데이트

Use when working with 3D-specific systems — materials, lighting, shadows, environment, global illumination, fog, LOD, occlusion culling, and decals in Godot 4.3+

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

jame581/GodotPrompter8542026년 10월 15일 업데이트

Use when building character abilities — Resource-based abilities with cost/cooldown/cast, buffs/debuffs, stat modifiers, gameplay tags, and HUD binding

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

jame581/GodotPrompter8542026년 10월 15일 업데이트

Use when creating Godot editor plugins — EditorPlugin, @tool scripts, custom inspectors, and dock panels

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

jame581/GodotPrompter8542026년 10월 15일 업데이트

Use when implementing AI movement — NavigationAgent2D/3D, steering behaviors, behavior trees, and patrol patterns

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

jame581/GodotPrompter8542026년 10월 15일 업데이트

Use when implementing animations — AnimationPlayer, AnimationTree, blend trees, state machines, sprite animation, and code-driven animation

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

jame581/GodotPrompter8542026년 10월 15일 업데이트

jame581의 스킬 모두 보기

이 스킬의 문제 신고