Skip to content

Nauvis fields: round cliffs, rocks, enemies and trees to f32; fix the no-cliff miss (#521) - #526

Merged
wormeyman merged 8 commits into
mainfrom
f32-521-nauvis-fields
Nov 25, 2026
Merged

wormeyman merged 8 commits into
mainfrom
f32-521-nauvis-fields

Conversation

@wormeyman

@wormeyman wormeyman commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Stack 1 of 5 for #521. Base main. Then #527 (Nauvis resources), #528 (Fulgora), #529 (Vulcanus), #530 (follow-ups).

This rounds the rest of Nauvis's noise fields to f32 one step at a time, the way the game evaluates them (the method from #452). It also closes #521's open question.

Results (tier 1, exact f32 matches)

field before after
elevation_nauvis_no_cliff, seed 123456 (of 26) 25 26
cliff_elevation_nauvis, two seeds (of 1,024) 699 / 648 1,024 / 1,024
rock_density, snapped (of 26) 17 26
enemy base field, basement 209/239, 126/159 239/239, 159/159
enemy base field, mid 0/602, 0/658 602/602, 658/658
enemy base field, live 1/191, 1/215 191/191, 215/215
every tree species (442 in all) 144 442
trees with moved levers 9 51

No tier-1 count went down. tree_04, which #452 moved from 11 to 10, is now 26.

The open question was not the lerp

#521 asked why elevation_nauvis_no_cliff missed one point by one f32 step while the full tree was exact. A probe read the game's intermediate values at that point on 2.1.23. The lerp's input and the lerp itself matched ours bit for bit. The difference was nauvis_persistance. It still used the old f64 amplitude form that #254 records at 81 of 152, and it was two f32 steps low. That error is under one step at the full tree's value of 22.1 but over one step at 4.35. So only the no-cliff variant showed it. Persistence now uses AmplitudeCorrectedGame, the form that scores 152 of 152 in #254. A control confirmed that 2.1.23 gives the same values as the 2.1.11 fixture on all 26 points.

What else changed

  • Cliffs, rocks: every step in f32, in the Lua's order.
  • Enemies: the field now uses the cone arithmetic read from the binary (ConeArithmetic::GameBinary), which Aquilo already uses. The spot quantity's cube is two f32 multiplies; one powf missed 11 and 142 points.
  • Trees: three things closed the last misses. temperature reached the species unrounded. output_scale 0.7 is the one value in the table where f32 and f64 differ. The species sum runs left to right; folding -0.5 + 0.2 * size into one constant scored worse.
  • A test-only field: the persistence input scale is kept for one unit test, so it is cfg(test).

Checks

  • cargo test -p fmw-noise --lib: 537 passed. scripts/verify-rust.sh: passed (cargo deny is not installed locally; CI runs it).
  • engine.wasm rebuilt. Tier 2: 154 Nauvis rows re-recorded, all in fields this PR changes. No other planet moved.
  • Full pnpm vp test: green. The Nauvis terrain render still matches the game on every pixel.

The four "probably not in scope" modules in #521 were also checked against the 2.1.23 binary. cliffs/collision.rs and voronoi_noise.rs match it. eval/memo_region.rs exists only in the port and nothing uses it. multioctave_noise.rs has one gap: the game holds persistence, output scale and octaves as f32. That fix is in #530.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Kd6o1cBoAGaJ1FoYPm6arC

Summary by CodeRabbit

  • Bug Fixes
    • Improved the accuracy of terrain, cliffs, enemy locations, rocks, and trees to better match in-game results.
    • Updated expected test results and checksums for the affected terrain configurations.

wormeyman and others added 7 commits November 24, 2026 17:45
…liff elevation is 26 of 26 (#521)

The one point elevation_nauvis_no_cliff missed was not the lerp. The game's
amplitude-corrected noise in nauvis_persistance is 0.0905596986 there; the
shipped f64 form gave 0.090559684. That moved nauvis_detail by 6e-8, which
is below one f32 step at the full tree's 22.1 but above one at 4.35. Given
the game's own t and detail, our lerp and nauvis_main already matched it.
Nauvis now uses AmplitudeCorrectedGame (152 of 152, #254). engine.wasm is
not rebuilt and tier 2 is not re-recorded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kd6o1cBoAGaJ1FoYPm6arC
cliff_elevation_nauvis and the six cliffiness sub-terms now go through
f32r one step at a time in the Lua's order, literals included
(0.01, 0.03, 0.05 narrowed before use; -2 added last in the
starting-area term; 1.5 + basis then + the lever).

Tier 1: cliff elevation 699 -> 1024 and 648 -> 1024 of 1024 (every
position exact at both seeds). The cliffiness gate stays at 0
mismatches; the closest margin to the cutoff moves by 3e-8 (3.402456e-3
-> 3.402424e-3, 2.344133e-4 -> 2.343776e-4), re-frozen. The cutoff
2 * gap ^ 1.5 is left in f64 (ungraded: margins are 2e-4 or more).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kd6o1cBoAGaJ1FoYPm6arC
rock_noise, rock_density and the three prototype probabilities now go
through f32r one step at a time in the Lua's order. The 0.25 is added to
the noise before the size term (the Lua adds left to right; the port
folded it into the size term). The 0.15 * frequency input scale is
narrowed, and range_select_base gets a local f32 form (the shared one is
used by Vulcanus and left alone).

Tier 1: rock_density 17 -> 26 of 26 (snapped), worst error exactly 0,
so the old < 9e-8 bound becomes an equality. The raw (unsnapped) arm
goes 7 -> 16. The three probabilities are ungraded in tier 1 (all are
negative at the fixture positions).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kd6o1cBoAGaJ1FoYPm6arC
- The cone now runs through the shared spot_cone_max with
  ConeArithmetic::GameBinary (the game's pi 3.1416, an f32 distance, the
  peak narrowed once), as Aquilo does, instead of a local per-step chain
  with the f64 pi.
- The spot radius and quantity (pi / 90 * r ^ 3, the cube two f32
  multiplies) are f32 steps, used for the cone, the blob term and the
  spot selection's quantity.
- The blob term reads basis_noise through the expression adapter
  (coordinates narrowed in f32), and the sum, the starting-area term and
  the blob arithmetic follow the Lua's order one f32 step at a time.

Tier 1 (basement / mid / live buckets, seed 123456 and 777771):
  basement 209 -> 239 of 239 and 126 -> 159 of 159
  mid      0 -> 602 of 602 and 0 -> 658 of 658
  live     1 -> 191 of 191 and 1 -> 215 of 215
Every position is exact and every worst error is 0. The test's
residual-ordering assertion has nothing left to order and now asserts
all residuals are 0. Selection's density stays the catalog's f64
expression (ungraded).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kd6o1cBoAGaJ1FoYPm6arC
The tree species and the shared forest-path cutout joined their exact
noise ops with f64 arithmetic. Each step now goes through f32r in the
Lua's order:

- shared.rs: the three path terms, trees_forest_path_cutout and
  trees_forest_path_cutout_faded.
- asymmetric_ramps.rs (its only caller is the species): literals
  narrowed, denominators folded from the f32 literals.
- field.rs: the species sum (climate + distance - size_offset +
  0.2 * size + small * 0.1, left to right), the distance term, cap,
  size_offset and 0.2 * size as f32 constants, and input_scale as
  f32(1/div) * f32(frequency).
- temperature is an f64 when it reaches the species, so it is rounded to
  f32 where they read it (eight species went to 26 at once).
- output_scale is narrowed to f32 before the noise. The three species at
  0.7 were the last misses; 0.7 is the one scale in the table that f32
  and f64 round differently.

Tier 1: trees_forest_path_cutout_faded 9 -> 26. Every species 26 of 26,
worst error 0 (before: tree_01 1, tree_04 10, tree_05 2, tree_02 9,
tree_03 7, tree_07 8, tree_02_red 1, tree_08 2, tree_09 13, tree_06 7,
tree_08_brown 9, tree_09_brown 8, tree_06_brown 8, tree_08_red 13,
tree_09_red 11). Total 144 -> 442 of 442. The moved-lever fixture goes
9 -> 51 of 51, and the unsnapped totals 99 -> 272 and 8 -> 36.

Not rebuilt: engine.wasm and the tier-2 checksums.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kd6o1cBoAGaJ1FoYPm6arC
154 Nauvis rows moved, all in fields this branch changes: elevation_nauvis
and its no-cliff variant (the persistence fix), cliff_elevation, the enemy
base field and probability, the three rock probabilities and density, and
every tree species with the forest-path cutouts and tree density. No row
moved on any other planet, and no key was added or removed.

The full vitest suite passes after the re-record, and the Nauvis terrain
render still matches the game on every pixel.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kd6o1cBoAGaJ1FoYPm6arC
The field that pins elevation_nauvis's persistence input_scale is read
only by a unit test, so clippy -D warnings rejected it as dead code in the
release build. It is now cfg(test). The persistence commit was also not
cargo-fmt clean. engine.wasm is rebuilt for both; no value changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kd6o1cBoAGaJ1FoYPm6arC
@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The PR updates Nauvis cliff, elevation, tree, enemy, and rock calculations to round intermediate operations through f32 in game evaluation order. It switches Nauvis persistence to AmplitudeCorrectedGame and updates fixture expectations and tier-2 checksums.

Changes: Nauvis field arithmetic

Layer / File(s) Summary
Elevation and cliff calculations
crates/fmw-noise/src/expressions/elevation_nauvis.rs, crates/fmw-noise/src/cliffs/fields.rs, crates/fmw-noise/src/fixtures.rs
Nauvis persistence evaluation now uses AmplitudeCorrectedGame. Cliff and elevation arithmetic rounds intermediate operations through f32. Fixture expectations and cutoff-margin measurements are updated.
Tree field calculations
crates/fmw-noise/src/trees/*, crates/fmw-noise/src/fixtures.rs
Tree ramps, species calculations, and forest-path cutouts round intermediate operations through f32. Tree fixture match counts and expected totals are updated.
Enemy-base calculations
crates/fmw-noise/src/enemies/field.rs, crates/fmw-noise/src/fixtures.rs
Enemy spot fields use shared cone geometry with GameBinary arithmetic. Quantity, radius, blob, and combined field calculations use explicit f32 rounding. Enemy fixture expectations are updated.
Rock field calculations
crates/fmw-noise/src/rocks/field.rs, crates/fmw-noise/src/fixtures.rs
Rock density, range selection, and prototype probabilities use explicit f32 rounding. Rock fixture expectations are updated.
Tier-2 checksum updates
test/fixtures/tier2-checksums.json
Expected checksums for cliff, elevation, enemy, rock, and tree fields are updated across the listed control configurations.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Possibly related issues

  • #452: The PR changes Nauvis elevation arithmetic and persistence evaluation to address exact-match differences in the elevation fields.
  • #254: The PR switches the Nauvis persistence field to AmplitudeCorrectedGame, the amplitude-corrected implementation discussed in this issue.

Possibly related PRs

  • FactoryGameFan/FactorioMapWebUI#522: Both PRs update Nauvis field arithmetic; this PR also changes persistence evaluation to address a remaining no-cliff elevation fixture mismatch.
Merge Risk: Low · up to 39e45 · assessed changes only

Path filters excluded changed files. This rating applies only to the assessed changes.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Linked Issues check Inconclusive Issue #521 tracks the f32 rounding of the whole remaining port. This PR (#526) covers these listed Nauvis items, based on the PR summary: cliffs/fields.rs (cliff elevation and main cliffiness), `roc… Provide current review evidence for PRs #527, #528, #529 and #530 at their listed heads. Each must show that its listed modules are rounded to f32 in Lua order and that its tier-1 counts were read. Confirm the state of spot_field.rs under…
Passed Passed checks: 3 passed

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: rounding the Nauvis cliff, rock, enemy, and tree field arithmetic to f32, plus the fix for the no-cliff miss. The raw summary confirms edits to cliffs, rocks, enemies,…
Out of Scope Changes check Passed All changed files in this PR map to modules listed in #521 or to their supporting tests and fixtures. The changed source files are cliffs/fields.rs, enemies/field.rs, `expressions/elevation_nauvis…
Full details: Title check

Explanation

The title names the main change: rounding the Nauvis cliff, rock, enemy, and tree field arithmetic to f32, plus the fix for the no-cliff miss. The raw summary confirms edits to cliffs, rocks, enemies, trees, and the elevation persistence change. The title is long (90 characters) but it matches the changeset and the linked objectives.

Full details: Out of Scope Changes check

Explanation

All changed files in this PR map to modules listed in #521 or to their supporting tests and fixtures. The changed source files are cliffs/fields.rs, enemies/field.rs, expressions/elevation_nauvis.rs, rocks/field.rs, trees/asymmetric_ramps.rs, trees/field.rs and trees/shared.rs. fixtures.rs and test/fixtures/tier2-checksums.json update expectations and re-recorded Nauvis rows for those fields, as #521's method requires. The cfg(test) persistence-input field supports a unit test of the persistence change. The enemies/field.rs change uses the shared cone geometry, which is part of the enemy field itself. It does not modify spot_field.rs, which #521 defers to #491. The engine.wasm rebuild is ignored and was not inspected.

Full details: Linked Issues check

Explanation

Issue #521 tracks the f32 rounding of the whole remaining port. This PR (#526) covers these listed Nauvis items, based on the PR summary: cliffs/fields.rs (cliff elevation and main cliffiness), rocks/field.rs, enemies/field.rs (cone arithmetic via ConeArithmetic::GameBinary, spot quantity cube as two f32 multiplies), trees/field.rs, trees/shared.rs, trees/asymmetric_ramps.rs, and the nauvis_persistance form in expressions/elevation_nauvis.rs, which resolves the no-cliff open question. The PR reports exact tier-1 matches for these fields and a 154-row tier-2 re-record. Remaining objectives sit in stack PRs whose evidence is uncertain: Nauvis resources (resources/nauvis_catalog.rs, resource_patches.rs, resolve_resource.rs, regular_patches.rs, starting_patches.rs, resource_math.rs) in #527; Fulgora (expressions/fulgora_roads.rs, fulgora_ruins.rs) in #528; Vulcanus modules in #529; and the multioctave_noise.rs persistence, output scale and octaves gap in #530. spot_field.rs is deferred to #491 and is unchecked in #521. No stack member has confirmed review evidence beyond #526, so these objectives are Uncertain. Within #526, the listed Nauvis objectives are Addressed on the reported evidence. This assessment relies on prior model summaries and reported test results. No direct code inspection was performed for this assessment.

Resolution

Provide current review evidence for PRs #527, #528, #529 and #530 at their listed heads. Each must show that its listed modules are rounded to f32 in Lua order and that its tier-1 counts were read. Confirm the state of spot_field.rs under #491, and confirm the multioctave_noise.rs change in #530.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c54f4017-3900-4717-8061-6c8baa042195
Commits

Reviewing files that changed from the base of the PR and between 366d502 and 39e45c0.

Files ignored due to path filters: 1

  • src/noise/wasm/engine.wasm is excluded by !**/*.wasm
Files selected for processing: 9

  • crates/fmw-noise/src/cliffs/fields.rs
  • crates/fmw-noise/src/enemies/field.rs
  • crates/fmw-noise/src/expressions/elevation_nauvis.rs
  • crates/fmw-noise/src/fixtures.rs
  • crates/fmw-noise/src/rocks/field.rs
  • crates/fmw-noise/src/trees/asymmetric_ramps.rs
  • crates/fmw-noise/src/trees/field.rs
  • crates/fmw-noise/src/trees/shared.rs
  • test/fixtures/tier2-checksums.json

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@claude

claude Bot commented Nov 25, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

🤖 Generated with Claude Code

@wormeyman
wormeyman merged commit f713f5c into main Nov 25, 2026
17 checks passed
@wormeyman
wormeyman deleted the f32-521-nauvis-fields branch November 25, 2026 15:15
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.

Round every noise-expression step to f32: the rest of the port after #452

1 participant