Skip to content

Cut terrain and forest from Strata's fractal noise - #33

Open
dmccoystephenson wants to merge 6 commits into
mainfrom
feat/fractal-fbm
Open

dmccoystephenson wants to merge 6 commits into
mainfrom
feat/fractal-fbm

Conversation

@dmccoystephenson

@dmccoystephenson dmccoystephenson commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

New maps are cut from Strata's fractal noise (strata/sim/noise.hpp), so rock outcrops and forest edges are ragged instead of round blobs. The shares of water, rock and resources stay as they were, colonies survive as often as before, and saves are unaffected.

Top-down maps from generate(), before and after

The game's own headless screenshots of seed 42, before and after

Top: maps from generate() (water blue, rock grey with pale stone, trees dark green, berries red, stockpile yellow). Bottom: CI's headless smoke screenshots (steading --new 42 --headless --ticks 400, then 100 more ticks), taken from the v0.2.1 main run and from this branch.

What changed

Edge Before After Edge dimension D before → after
Rock 2 octaves of value noise (12 and 5 cells) fBm, 5 octaves, gain 0.65, first layer 16 cells across 1.02 → 1.15
Forest 1 octave (7 cells) fBm, 3 octaves, gain 0.65, first layer 7 cells across 1.05 → 1.29
Water same field as rock the first 3 octaves of the same elevation field (down to 4 cells) 1.03 → 1.04

D is the box-counting dimension of each mask's edge at box sizes of 1–8 cells. Rock and water were measured on 512 × 512 maps for seeds 1–8. Forest was measured on the noise field's forest mask. Strata's header measures gain 0.65 at about D 1.19. Natural coastlines are about 1.1–1.3. A cell is the finest scale here, so the octaves stop at about one cell.

Why the water stays smoother: settlers have no pathfinding. systems.cpp steps greedily toward a target and slides along water when blocked, so shores with one- and two-cell inlets trap them. With five octaves for water as well, a no-player run of seeds 1–1000 lost 14.0% of colonies by tick 1000 (140), against 9.9% (99) for v0.2.1. Cutting water from three octaves brings it back to 10.1% (101). Mean settlers at tick 1000: 16.1 (v0.2.1: 16.2–16.7). Mean buildings: 13.6 (v0.2.1: 13.7–14.0). Shores are still more irregular at the 4–16-cell scale. Roughening them fully is better left until settlers can path round water.

Balance. The thresholds were set so the mean shares over seeds 1–256 (64 × 64) match the old generator:

v0.2.1 this PR
water 11.1% 11.4%
rock (incl. stone) 9.5% 9.1%
trees 15.3% 15.3%
stone 2.8% 2.7%
berries 1.14% 1.13%

Per-seed spread is about the same (standard deviation over seeds 1–256: water 5.3% vs 4.7%, rock 4.2% vs 4.2%). A single seed can still move a lot: seed 42 has fewer rock outcrops than it used to. A new section in test_generate checks the shares over 64 seeds.

(The main commit's message says 9.6% (96 lost). That figure was measured with the water threshold at −0.334 before it was rounded to −0.33. The figure for the code as committed is 10.1%.)

Save compatibility

  • A save holds the whole map (toWorld writes every grid channel into the base layer). Loading never calls generate(), and globals.seed is used only at generation. Nothing in an existing save is re-derived from the seed, so no generator version needs recording.
  • Test: test_save_fixtures now pins the fingerprint() each v1 fixture loads as: v1-seed42-tick500 → 05ffc670c14bab66, v1-frost-huts-seed7-tick600 → 50ec76feccbfd0e2. These pins were recorded from CI on the first commit, before the generator changed (run 43662799008; GCC 13 on Linux and MSVC agree). They still pass with the new generator.
  • New games from a given seed get a different map. That includes the browser game (which has no saves) and steading-replay --new. So the pinned seed-42 fingerprint moves from 011ed2b2f364b21b to 09826a6da618223a in test_determinism, ci.yml, browser.yml, web/smoke/smoke.cjs, README.md and docs/WEB.md.

Strata: vendored, pin unchanged

noise.hpp landed in Strata PR #103 (649f0a5 on main). That commit is after v0.7.0 and is not in a release. Two things kept this PR from linking strata::sim and bumping the pin:

  • steading_colony is deliberately Strata-free: it builds with CMake 3.16, needs no OpenUSD, and the rules jobs build it without Strata.
  • The browser build sets STRATA_WITH_SIM=OFF.

So noise.hpp and noise.cpp are vendored unchanged in third_party/strata_noise (with Strata's MIT licence and a README naming the commit), the same way third_party/usd_recorder is vendored. strata.ref stays at v0.7.0 (20827c3), so none of Strata main's other unreleased changes since v0.7.0 come in (ABI 1.13–1.16, the save-core fixes in #92). test_determinism checks the copy against the values Strata's own unit test pins. Once a Strata release carries noise.hpp, linking strata::sim instead is an option. docs/THIRD-PARTY.md mentions the vendored copy.

Tests

  • Locally (GCC 9.4, rules build): ctest 5/5 pass.
  • No-player sweeps with steading-sim over seeds 1–1000 (numbers above). Coverage was measured with a scratch tool linking steading_colony.
  • The desktop game cannot be built on the local box (glibc 2.31 against the OpenUSD prebuilt for 24.04). The save fixtures, the game build and the headless smoke were checked in CI only.

Not done here

Not merged: merging to main deploys the browser game.

drafted by Claude on behalf of Daniel Stephenson

🤖 Generated with Claude Code

https://claude.ai/code/session_01LYNeukDJfWGrEeQGR8FbX9

dmccoystephenson and others added 6 commits November 14, 2026 18:22
The two v1 slots under tests/fixtures/ are now also checked against the
fingerprint() of the colony as loaded. The pins are recorded from CI on
this commit, before any change to world generation, so a later generator
change that touched a loaded save would fail here.

drafted by Claude on behalf of Daniel Stephenson

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LYNeukDJfWGrEeQGR8FbX9
The values are what CI printed for the previous commit (run 43662799008),
on GCC 13 in ubuntu:24.04 and on MSVC alike, with world generation still
as v0.2.1 has it.

drafted by Claude on behalf of Daniel Stephenson

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LYNeukDJfWGrEeQGR8FbX9
New maps drew elevation from two octaves of value noise and forest from
one, so lake shores, rock outcrops and forest edges were round blobs.
They are now cut from Strata's fBm (strata/sim/noise.hpp, vendored
unchanged in third_party/strata_noise from Strata main at 649f0a5, which
is after v0.7.0 and not in a release; the Strata pin stays at v0.7.0).

- Rock: five octaves, gain 0.65, first layer 16 cells across. Edge
  box-counting dimension at 1-8 cells on 512 x 512 maps (seeds 1-8):
  1.02 before, 1.15 after.
- Forest: three octaves, gain 0.65, first layer 7 cells across. Edge
  dimension of the forest mask: 1.05 before, 1.29 after.
- Water: the first three octaves of the elevation field (down to four
  cells). Settlers have no pathfinding, and the one- and two-cell inlets
  of a fully rough shore trapped them: with five octaves for water too,
  a 1,000-seed run with no player lost 14% of colonies by tick 1000
  instead of 10%. With three, 9.6% (96 of seeds 1-1000) against 9.9%.
  Shore dimension: 1.03 before, 1.04 after.

Thresholds were set so the mean shares over seeds 1-256 (64 x 64) match
the old generator: water 11.4% (was 11.1%), rock 9.1% (9.5%), trees
15.3% (15.3%), stone 2.7% (2.8%), berries 1.13% (1.14%). A new test in
test_generate checks the shares over 64 seeds.

Saves are not affected: a save holds the whole map, and nothing is
re-derived from the seed on load. test_save_fixtures pins the
fingerprint both v1 fixtures load as, recorded before this change, and
still passes. New games from a given seed (including the browser game
and steading-replay --new) get a different map, so the pinned seed-42
fingerprint moves from 011ed2b2f364b21b to 09826a6da618223a in
test_determinism, ci.yml, browser.yml, the smoke test and the docs. The
determinism test also checks the vendored noise against the values
Strata's own unit test pins.

drafted by Claude on behalf of Daniel Stephenson

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LYNeukDJfWGrEeQGR8FbX9
Top-down maps from generate() for seeds 42 and 7 at 64 x 64 and seed 42
at 192 x 192, with the v0.2.1 generator and with fractal noise. Water is
blue, rock grey (stone pale), trees dark green, berries red and the
stockpile yellow.

drafted by Claude on behalf of Daniel Stephenson

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LYNeukDJfWGrEeQGR8FbX9
MSVC warns (C4804) on bool / double, and the rules job builds with
warnings as errors.

drafted by Claude on behalf of Daniel Stephenson

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LYNeukDJfWGrEeQGR8FbX9
CI's headless smoke screenshots (steading --new 42 --headless --ticks
400, then 100 more) from the v0.2.1 main run and from this branch.

drafted by Claude on behalf of Daniel Stephenson

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LYNeukDJfWGrEeQGR8FbX9
@dmccoystephenson
dmccoystephenson marked this pull request as ready for review November 15, 2026 01:40
@dmccoystephenson

Copy link
Copy Markdown
Member Author

Review of head feat/fractal-fbm (6 commits). No review had been posted on this PR yet, so this comment is the review of record. It is not independent of the author.

Verdict: no blocking defect found. Not merged. The PR modifies do-not-auto-merge paths (.github/workflows/ci.yml, .github/workflows/browser.yml, CMakeLists.txt) and moves the pinned determinism fingerprint (011ed2b2f364b21b → 09826a6da618223a). Both need the owner's approval. A merge also deploys the browser game, as the PR body says.

Rubric

  • CI: PASS. All jobs are green on the head: rules on gcc-13, clang-18, asan-ubsan and msvc; game on Strata on Linux and on Windows/MSVC; and the browser build and smoke test. The new fingerprint matches across GCC, Clang, MSVC and wasm, which is the cross-compiler evidence the determinism contract needs. The local build was not run in this session, so CI on the exact head SHA is the only verification.
  • Save integrity: PASS. No CHECK is removed from test_saves.cpp, test_determinism.cpp or test_systems.cpp. test_save_fixtures.cpp gains a pinned fingerprint() for each v1 fixture as loaded, recorded before the generator changed. This is a direct guard that a generator change cannot alter a saved colony, and it strengthens the save tests.
  • Schema untouched: PASS. src/colony/schema.h, kSchemaVersion, strata.ref and content/prefabs.usda are not in the diff.
  • Fingerprint: PASS, with an owner hand-off. The PR body names the intentional rules change (world generation) that moves the pin. Every copy of the pin was updated together: test_determinism.cpp, ci.yml, browser.yml, web/smoke/smoke.cjs, README.md and docs/WEB.md. A git grep of the branch for 011ed2b2f364b21b finds nothing, so no stale copy remains.
  • Determinism: PASS. noise.cpp is compiled into steading_colony, so it inherits -ffp-contract=off (CMakeLists.txt:63-65, non-MSVC). It uses only integer hashing, std::floor and plain double arithmetic. It has no <random>, no wall-clock time and no unordered iteration.
  • Layering: PASS. src/colony now includes strata/sim/noise.hpp, but that header comes from the vendored, USD-free third_party/strata_noise, not the Strata engine. The rules jobs still build without Strata or OpenUSD. No pxr/ include was added.
  • Tests-new: PASS. test_determinism checks the vendored latticeHash, valueNoise and fbm against the values Strata's own unit test pins. test_generate checks the terrain and resource shares over 64 seeds.
  • Docs: PASS. README.md, docs/WEB.md and docs/THIRD-PARTY.md were updated. No control, flag or mod key changed. The out-of-date timelapse.gif and mods-frost-huts.png are listed under "Not done here".
  • Privacy: PASS. The diff and the PR text name only Preponderous-Software/strata, which is public (gh repo view … --json isPrivate → false).

Notes (non-blocking)

  • src/colony/rng.h:39: valueNoise(uint64_t, double, double) is no longer called by any production code. Only test_determinism.cpp:162-208 still uses it. It could be removed in a follow-up, or kept on purpose as a pinned primitive. Either is fine, but the choice should be deliberate.
  • tests/test_generate.cpp (new shares section): the terrain and resource codes are written as bare integers (terrain[i] == 1, resType[i] == 3). static_cast<int32_t>(Terrain::Water) and the matching Resource:: values would keep the test correct if the enums are ever reordered.
  • third_party/strata_noise: the vendored files could not be compared byte for byte with Strata commit 649f0a5 in this session, because the contents API was not available. The pinned-value test in test_determinism passing on every compiler is strong indirect evidence that the copy is faithful.
  • PR Start a colony on a real map (--map: a heightmap world package) #32 (--map) also edits src/colony/generate.cpp and states that the old pin 011ed2b2f364b21b still passes. Whichever PR merges second will need a rebase, and Start a colony on a real map (--map: a heightmap world package) #32's pin and its new steading-sim --map CI step need to be checked against the new generator.

Owner action needed: approve the fingerprint move and the workflow and CMakeLists.txt changes, then squash-merge when the browser deploy is wanted.

This review was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant