All skills
thedivergentai avatar

/godot-procedural-generation

@9d6e91e

Expert blueprint for procedural content generation (dungeons, terrain, loot, levels) using FastNoiseLite, random walks, BSP trees, Wave Function Collapse, and seeded randomization. Use when creating roguelikes, sandbox games, or dynamic content. Keywords procedural, generation, FastNoiseLite, Perlin noise, BSP, drunkard walk, Wave Function Collapse, seeding.

Use this Skill: https://skilld.dev/gh/thedivergentai/gd-agentic-skills/godot-procedural-generation

This session only. Nothing lands on disk.

referencesalgorithm-recipes.md

≈703 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Procedural Algorithm Recipes (load on demand)

MANDATORY when implementing drunkard walk, BSP, noise biomes, WFC lite, or loot tables beyond the Golden Path scripts. All heavy work off-thread; SceneTree commits on main thread only.

Drunkard's walk (organic caves)

func generate_dungeon(width: int, height: int, fill_percent: float = 0.4) -> Array:
    var grid: Array = []
    for y in height:
        grid.append(Array().duplicate(width))  # 1 = wall
    var x := width / 2
    var y := height / 2
    var floor_tiles := 0
    var target := int(width * height * fill_percent)
    var rng := RandomNumberGenerator.new()
    while floor_tiles < target:
        if grid[y][x] == 1:
            grid[y][x] = 0
            floor_tiles += 1
        match rng.randi() % 4:
            0: x = clampi(x + 1, 0, width - 1)
            1: x = clampi(x - 1, 0, width - 1)
            2: y = clampi(y + 1, 0, height - 1)
            3: y = clampi(y - 1, 0, height - 1)
    return grid

See drunknard_walk_path.gd.

Perlin / FastNoiseLite biomes

var noise := FastNoiseLite.new()
noise.seed = run_seed
noise.frequency = 0.05
# Prefer noise.get_image() once — never sample per frame in _process

See fast_noise_noise2d_master.gd.

BSP room split

Full BSPRoom.split() recursion — bsp_tree_rooms.gd. Validate min_size before split to avoid degenerate leaves.

Random loot tables

func roll_rarity(rng: RandomNumberGenerator) -> String:
    var roll := rng.randf()
    if roll < 0.6: return "common"
    if roll < 0.85: return "uncommon"
    if roll < 0.95: return "rare"
    return "legendary"

Pair with godot-resource-data-patterns for ItemData resources.

WFC lite loop

Always cap iterations — impossible adjacency rules can spin forever. See wave_function_collapse_lite.gd.

Expert: graph-before-geometry

Build room graph with AStar2D first — validate reachability before spawning tiles. proc_gen_graph_layout.gd.

Expert: marching cubes / ArrayMesh

Vertices/normals in worker thread → add_surface_from_arrays on main thread → create_trimesh_collision() only for active chunk. proc_gen_marching_cubes_base.gd.

Serialization contract

Persist seed + player deltas — not full chunk arrays unless required. proc_gen_seed_history.gd.

Godot 4.7

Path3D snap-to-colliders for spline roads/rivers on terrain colliders.

Source: SKILL.md on GitHub

1 warning17d5 checks · Risk SAFE
  • Gen Agent Trust Hub17d

    The skill provides a suite of GDScript algorithms for procedural content generation in Godot, including noise functions, BSP trees, and Wave Function Collapse. It follows security best practices, lacks any network or file-system operations, and contains no malicious obfuscation or injection patterns.

  • Socket17d

    No alerts

  • Snyk17d

    Risk: LOW · No issues

  • Runlayer7mo

    3/3 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 9d6e91e. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 3 weeks ago.

Activeupdated 2 months ago

README badge

README badge for thedivergentai/gd-agentic-skills/godot-procedural-generation