# Generate worlds that work

Lesson 8 · Build

Use seeded generation and deterministic checks to create varied maps that remain completable.

## Outcomes

- Generate a repeatable map from a recorded seed and version.
- Check reachability and resource sufficiency without an LLM judge.
- Refine or reject a world within a fixed attempt ceiling.

Prerequisites: Lesson 7 and a bounded task harness.

Deliverable: Three reproducible Signal Garden maps with automated playability reports.


## Variety is not the goal

Procedural generation is valuable when it produces useful variation inside authored rules. Signal Garden needs a compact place to navigate, not an infinite landscape. A generated world succeeds only when the player can collect enough cells, reach all three relays, and return to the beacon.

Use a **generate → evaluate → refine or reject** loop. Code should handle rules that code can prove. An AI collaborator can suggest layout motifs or diagnose a rejected report, but it should not be the final judge of reachability.

## Make every world reproducible

Record a seed, generator version, input parameters, and output hash:

```text
seed: 18427
generatorVersion: 3
width: 24
height: 18
relayCount: 3
cellCount: 5
```

A fixed seed makes a random sequence repeatable within the same implementation. The [Godot random-number documentation](https://docs.godotengine.org/en/stable/tutorials/math/random_number_generation.html) also motivates recording implementation details: after the generator changes, the same seed may no longer describe the same result. A bug report needs both.

## Encode playability as checks

Represent the map as walkable and blocked cells plus typed landmarks. Then check:

1. The beacon and every relay occupy walkable cells.
2. A flood-fill or pathfinder reaches every relay from the beacon.
3. Reachable usable cells cover the sum of all three relays’ `requiredCells` values.
4. No required item is inside blocked terrain or another object.
5. The repaired route can return to the beacon.
6. Landmarks remain spaced enough to be readable.

The first five are deterministic. Spacing can begin as a numeric threshold, then be tuned through playtests. Keep “valid” separate from “good”: a valid map can still be dull.

Add a compact quality summary after the hard checks: shortest completion distance, number of meaningful route branches, and how quickly the first objective becomes visible. These measurements do not declare a map fun. They help compare candidates and catch a generator drifting toward long empty walks.

## Refine with a ceiling

When evaluation fails, pass the exact failure back to a constrained refiner: “Floodplain relay unreachable from beacon; nearest reachable tile is (17, 9).” Permit a local move, not a complete redesign. Re-run all checks after the change because fixing one route can block another.

Stop after three attempts. Keep the rejected seed and report as a regression fixture. Generators improve faster when failures become durable tests rather than disappearing into retries.

For Signal Garden, refinement should move a blocked landmark to the nearest valid tile or regenerate one local region. Preserve the seed, original report, and applied patch so the repaired world remains explainable.

## Failure modes and tradeoffs

**Seed amnesia** makes a broken map impossible to reproduce. **Judge substitution** asks a model whether the layout “looks playable” instead of running pathfinding. **Constraint pile-up** creates so many rules that all maps look the same. **Blind refinement** regenerates everything and cannot explain why the next result is better.

Strict constraints reduce novelty; loose constraints increase rejection and testing cost. Author a few meaningful choices—safe versus scenic route, exposed versus sheltered cell—rather than maximizing geometric difference.

## Build task: three accepted maps

Generate at least ten candidate seeds. Run the same report for each, accept three, and preserve two interesting failures. For accepted maps, walk the shortest route and one alternate route manually. Record completion time and any confusing landmark.

```text
You are reviewing a Signal Garden map report, not judging from an image.
Given the generator parameters and deterministic failures, propose one minimal
parameter or placement change. Preserve the beacon, three-relay objective, and
offline rules. Do not waive a failed reachability or resource check. Return:
DIAGNOSIS, ONE CHANGE, CHECKS TO RERUN, and STOP IF UNSAFE.
```

## Completion evidence

Each accepted map must reproduce from its seed and generator version, pass every deterministic rule, and support a manual start-to-beacon run. Each rejected map must fail with a specific report. Typed output can stabilize the report shape, but semantic checks still decide acceptance; that division reflects the caution in the [Structured Outputs documentation](https://developers.openai.com/api/docs/guides/structured-outputs).



## Knowledge check

Why record both a random seed and generator version?

1. The same seed can produce a different map after generation logic changes.
2. A seed guarantees every map is fun.
3. The version makes random generation less expensive.

Answer: 1. Reproduction depends on the algorithm as well as its seed; playability still needs separate checks.

## Further reading

- [Structured model outputs](https://developers.openai.com/api/docs/guides/structured-outputs) — OpenAI
- [Random number generation](https://docs.godotengine.org/en/stable/tutorials/math/random_number_generation.html) — Godot documentation

Sources checked 1 December 2026. Signal Garden is an original teaching scenario.
