You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Nauvis fields: round every step to f32, offset first (#452) - #522
Four Nauvis fields now match the game at every point of their fixtures. The noise ops were already exact. What was wrong was the arithmetic joining them: we did it in f64, and the game does it in f32, one step at a time.
oracle-cliff-elevation, two seeds (reads cliff_level)
355 / 281
699 / 648 of 1024
oracle-trees, all 17 fields (read moisture)
120
144 of 442
The four elevation counts now have a worst error of exactly 0, so their bounds became equalities.
The two causes
The glue ran in f64. The game rounds every literal and every operation to f32, left to right as the Lua writes it. A new helper, eval::math::f32r, does one such step. plateaus, cliff_level, aux, moisture, elevation_lakes and elevation_nauvis now use it at each step.
Nauvis's offset_x is 10000 / 1.5 = 6666.67, which is not an f32. The game holds it as an f32 constant, so x + offset_x adds the rounded value. We added the f64 value and rounded the sum, which is a different point. Rounding the offset alone takes elevation_nauvis from 8 to 10. The f32 steps alone take it to 19. Only both reach 26.
One commit per field
aux and the shared plateaus / cliff_level
moisture
elevation_lakes and elevation_island
elevation_nauvis, with the offset and nauvis_segmentation_multiplier folded in f32
Docs: a new port rule in CLAUDE.md, and two notes corrected
Each commit moves its own tier-1 counts, rebuilds engine.wasm, and re-records only the tier-2 rows it moved: 239, 209, 12 and 21 of the 504 Nauvis rows. No tier-3 row moves, and neither does the Nauvis terrain count in #400 (1 pixel). Each commit's message says what moved.
Things a reviewer should know
One count went down.tree_04 fell from 11 to 10 when moisture became exact, while the tree total rose from 120 to 144. The trees' own arithmetic is still f64, so some of their old matches were luck that a correct input undid.
One point is still off.elevation_nauvis_no_cliff misses one point at seed 123456 by one f32 step, where the full tree is exact. I tried rounding the constant-ended lerp once instead of twice, and it got worse (9 misses). The test records it as open. Reading how the game compiles that lerp, in the binary, is the next step.
The aux bias test changed. It used to check the bias shift to 1e-9. That can't hold for an f32 field, so it now checks to one f32 step at 1.0. The measured worst is 0.7 of a step.
How I found it: I read frankh/factorio-mapgen's source, which builds its program from the game's Lua with Math.fround at every op. I did not run its code.
Follow-ups this points at
The tile scores, the tree species and cliff_elevation_nauvis still do their own arithmetic in f64. The last Nauvis pixel's grass-1/grass-3 gap barely moved once its inputs were exact, so the tile scores are the next suspect.
water_level is narrowed where it is used, but the caller computes 10 * log2(size) in f64. That is exact at the default size only.
The game evaluates a noise expression one f32 operation at a time,
literals included. The Nauvis port combined its (already exact) noise
fields in f64, which held aux at 14 of 26 against the game.
- eval::math::f32r: the per-step rounding, documented once.
- nauvis_hills_cliff_level and nauvis_plateaus: each step through f32r.
- aux_nauvis: the same, with 0.5 + bias folded first as the game does.
Tier 1: aux 14 -> 26 of 26. Nauvis cliff elevation, which reads
cliff_level, 355 -> 699 and 281 -> 648 of 1024 (its own arithmetic is
still f64). The last-pixel diagnostic moves grass-3 from 90 to 80 ULPs
high. The aux bias test now bounds the shift at one f32 step (measured
worst 0.7 of a step), since aux is f32.
Tier 2: 239 of 504 Nauvis rows re-recorded (plateaus, cliffLevel, aux
and everything downstream of them). Tier 3 and the Nauvis terrain
count (1 pixel) do not move.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kd6o1cBoAGaJ1FoYPm6arC
moisture_nauvis, its starting-area blend and the three forest-path
cutouts now go through f32r one step at a time in the Lua's order. The
blend's constants (bias, slider change, frequency / 400) are folded in
f32, as the game folds them.
Tier 1: moisture 18 -> 26 of 26. Every tree species reads moisture, so
the tree layer moves too: 120 -> 144 exact of 442 (unsnapped 85 -> 99).
Eight species rise and tree_04 falls 11 -> 10; the species' own
arithmetic is still f64, so some old matches were coincidences. The
last-pixel diagnostics move: grass-3 leads grass-1 by 63 ULPs (was 53).
Tier 2: 209 of 504 Nauvis rows re-recorded (moisture and what reads
it). Tier 3 and the Nauvis terrain count do not move.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kd6o1cBoAGaJ1FoYPm6arC
make_0_12like_lakes and finish_elevation now go through f32r one step
at a time in the Lua's order. segmentation_multiplier, water_level and
0.1 * segmentation_multiplier are narrowed the way the game folds them,
and the persistence clamp uses the f32 literals 0.1 and 0.9.
Tier 1: elevation_lakes 21 -> 26 of 26 and elevation_island 19 -> 26,
both with worst error exactly 0, so their bounds become equalities.
The persistence clamp test compares against the f32 bounds (its count,
430, is unchanged).
Tier 2: 12 Nauvis rows re-recorded (elevationLakes, elevationIsland).
The 18 elevation:render rows do not move.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kd6o1cBoAGaJ1FoYPm6arC
elevation_nauvis_function now goes through f32r one step at a time in
the Lua's order, and two constants are folded in f32 the way the game
holds them:
- offset_x = 10000 / nauvis_segmentation_multiplier is 6666.67 at the
default, which is not an f32. The game adds the ROUNDED constant to
x; we added the f64 one and rounded the sum. Alone this takes the
tree from 8 to 10; the f32 steps alone take it to 19; together, 26.
- nauvis_segmentation_multiplier = 1.5 * control:water:frequency, in
the shared layer. Exact at the default, so only moved sliders see it.
Tier 1: elevation_nauvis 8 -> 26 of 26 (worst error 0, so the bound is
now an equality). elevation_nauvis_no_cliff 6 -> 25 and 4 -> 26 at its
two seeds. Its one miss is one f32 step at a point where the full tree
is exact; rounding the constant-ended lerp once was tried and is worse
(9 misses), so it is recorded as open, to be read in the binary.
Tier 2: 21 Nauvis rows re-recorded (elevationNauvis, its no-cliff
variant, and the water, deepwater and sand-1 tiles at moved sliders).
Tier 3 and the Nauvis terrain count (1 pixel) do not move.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kd6o1cBoAGaJ1FoYPm6arC
- CLAUDE.md: a rule beside the other determinism rules: wrap each
expression step in f32r and narrow non-exact constants before they
meet a coordinate.
- rust-wasm-port.md: the "depth beats everything" bullet is refuted;
the Nauvis residual was the f64 glue, not the depth.
- tile-correction-NOTES.md: the last Nauvis pixel barely moved once its
three inputs were exact, so the tile scores' own f64 arithmetic is
the next suspect.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kd6o1cBoAGaJ1FoYPm6arC
Review was skipped as selected files did not have any reviewable changes.
Files ignored due to path filters: 1
src/noise/wasm/engine.wasm is excluded by !**/*.wasm
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: 4de7cb1d-ac06-41fd-a697-111b10cda5d1
Commits
Reviewing files that changed from the base of the PR and between 1a1bfb9 and 1a1bfb9.
Files ignored due to path filters: 1
src/noise/wasm/engine.wasm is excluded by !**/*.wasm
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
Noise evaluation now rounds intermediate expression operations and selected constants to f32 across elevation, climate, and shared Nauvis calculations. Fixture expectations and tier-2 checksums were updated for the resulting outputs. Documentation describes the rounding rule and reports remaining tile-score differences.
Changes: Per-step f32 noise evaluation
Layer / File(s)
Summary
Rounding helper and evaluation rule crates/fmw-noise/src/eval/math.rs, CLAUDE.md, docs/rust-wasm-port.md
A public f32r helper narrows values to f32 and returns them as f64. The porting guidance describes rounding each expression step, including constants.
Shared Nauvis and climate calculations crates/fmw-noise/src/expressions/nauvis_shared.rs, crates/fmw-noise/src/expressions/nauvis_climate.rs
Shared Nauvis, aux, and moisture calculations now round intermediate operations and selected constants through f32r. Moisture stores a precomputed, f32-rounded region scale.
The elevation-lakes and Nauvis elevation calculations now round intermediate arithmetic and selected stored values through f32r. Persistence tests use f32-rounded clamp bounds.
Fixture and checksum updates crates/fmw-noise/src/fixtures.rs, test/fixtures/tier2-checksums.json, docs/noise/tile-correction-NOTES.md
Fixture match counts and checksum values were updated. The tile-correction note reports updated Nauvis score gaps and identifies tile-score f64 arithmetic as a remaining suspect.
FactoryGameFan/FactorioMapWebUI#490 — It adds frozen checks for Nauvis score differences that this PR’s expression updates and fixture changes also affect.
Merge Risk: Minimal · up to 1a1bf · assessed changes only
Path filters excluded changed files. This rating applies only to the assessed changes.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the main change: Nauvis composite-field paths now round each arithmetic step to f32, with the elevation_nauvis offset applied first. The changeset matches this. The raw summary shows f…
Linked Issues check
Evidence is the PR description, the AI summary, and the fixture-test changes. I did not inspect the repository directly. Objectives from [#452] and [#255] (grouped, since both concern the same four fi…
Out of Scope Changes check
Every listed change serves the four target fields or their direct dependents: - crates/fmw-noise/src/eval/math.rs: adds the f32r helper used by all four field trees. - nauvis_shared.rs, nauvis_climate…
Full details: Title check
Explanation
The title names the main change: Nauvis composite-field paths now round each arithmetic step to f32, with the elevation_nauvis offset applied first. The changeset matches this. The raw summary shows f32r rounding added across elevation_lakes, elevation_nauvis, nauvis_climate, nauvis_shared, the new f32r helper, fixtures, and CLAUDE.md. The PR objectives report the same per-step f32 approach for aux, moisture, elevation_lakes, elevation_island, and elevation_nauvis. The title uses a reference (#452) that matches the linked issue. It is specific and does not use vague terms.
Full details: Linked Issues check
Explanation
Evidence is the PR description, the AI summary, and the fixture-test changes. I did not inspect the repository directly. Objectives from [#452] and [#255] (grouped, since both concern the same four fields):
[#452] Reach 26/26 exact f32 matches for elevation_nauvis, elevation_lakes, moisture, and aux, graded per field. The PR reports 26 of 26 for each. The fixture tests now assert exact f32 matches with zero residuals. Changes: f32r helper in eval/math.rs; per-step f32 arithmetic in nauvis_shared.rs, nauvis_climate.rs (aux, moisture), elevation_lakes.rs, and elevation_nauvis.rs; the Nauvis offset rounded to f32 before the add. Each field has its own commit, as the issue's plan asks.
[#255] Resolve the moisture and aux 1-4 ulp residual as an expression-tree difference, without raising bounds or re-capturing, and keep exact-match scoring. The PR attributes the residual to f64 arithmetic between noise operations, not to the tree shape. Its fixes are per-step f32 rounding, which keeps exact-match scoring. It does not re-capture fixtures.
Unmet or deferred items, which this PR does not claim to complete: [#254] amplitude_corrected_multioctave_noise (separate investigation in the issue); the 2.0.77 vs 2.1.20 check with factorio-oracle refs grep, which the PR does not report; and one residual point in elevation_nauvis_no_cliff at seed 123456. The PR explicitly records these as open. The issue assigns #254 as a separate change, so its absence does not fail this PR. The no-cliff point is an acknowledged residual in a field that the issue lists as graded separately and is not among the four named targets.
Uncertainty: the aux bias test tolerance changed from 1e-9 to one f32 step (measured worst 0.7 of a step). [#255] says not to raise bounds to accommodate the residual. The PR's stated reason is that the test checks an f32 field, so the old tolerance cannot hold. This should be reviewed against that requirement.
Full details: Out of Scope Changes check
Explanation
Every listed change serves the four target fields or their direct dependents:
crates/fmw-noise/src/eval/math.rs: adds the f32r helper used by all four field trees.
nauvis_shared.rs, nauvis_climate.rs, elevation_lakes.rs, elevation_nauvis.rs: per-step f32 arithmetic for the target fields. elevation_island shares the elevation_lakes tree.
nauvis_shared.rs cliff_level and plateaus: shared inputs to the target fields. The PR also moves cliff-elevation counts because cliff_elevation reads cliff_level.
fixtures.rs and tier2-checksums.json: expected counts updated to the new engine output. The PR says tier-3 rows and the Nauvis terrain count do not move. Tier-2 changes follow from moisture and elevation changes.
CLAUDE.md, docs/rust-wasm-port.md, docs/noise/tile-correction-NOTES.md: document the f32 port rule and correct two notes about the residual's cause.
The tree_04 decrease (11 to 10) is a consequence of the moisture input change. The PR states that tree arithmetic is still f64. No change is unrelated to #452 or #255. Not verified: whether each tier-2 checksum rewrite is limited to the rows the PR names. I accept the PR's per-commit description of this.
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.
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
No issues found. Checked for bugs and CLAUDE.md compliance.
Scope note: this was a single-pass read of the Rust diff (f32 rounding changes in eval/math.rs, elevation_lakes.rs, elevation_nauvis.rs, nauvis_climate.rs). I did not run the build or tests, and I did not review the regenerated engine.wasm or the re-recorded tier-2 checksums.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #452. Closes #255.
Four Nauvis fields now match the game at every point of their fixtures. The noise ops were already exact. What was wrong was the arithmetic joining them: we did it in f64, and the game does it in f32, one step at a time.
The numbers (tier 1, exact f32 matches)
oracle-auxoracle-moistureoracle-elevation-lakesoracle-elevation-islandoracle-elevation-nauvisoracle-elevation-nauvis-no-cliff, seed 123456 / 777771oracle-cliff-elevation, two seeds (readscliff_level)oracle-trees, all 17 fields (readmoisture)The four elevation counts now have a worst error of exactly 0, so their bounds became equalities.
The two causes
eval::math::f32r, does one such step.plateaus,cliff_level,aux,moisture,elevation_lakesandelevation_nauvisnow use it at each step.offset_xis10000 / 1.5= 6666.67, which is not an f32. The game holds it as an f32 constant, sox + offset_xadds the rounded value. We added the f64 value and rounded the sum, which is a different point. Rounding the offset alone takeselevation_nauvisfrom 8 to 10. The f32 steps alone take it to 19. Only both reach 26.One commit per field
auxand the sharedplateaus/cliff_levelmoistureelevation_lakesandelevation_islandelevation_nauvis, with the offset andnauvis_segmentation_multiplierfolded in f32Each commit moves its own tier-1 counts, rebuilds
engine.wasm, and re-records only the tier-2 rows it moved: 239, 209, 12 and 21 of the 504 Nauvis rows. No tier-3 row moves, and neither does the Nauvis terrain count in #400 (1 pixel). Each commit's message says what moved.Things a reviewer should know
tree_04fell from 11 to 10 whenmoisturebecame exact, while the tree total rose from 120 to 144. The trees' own arithmetic is still f64, so some of their old matches were luck that a correct input undid.elevation_nauvis_no_cliffmisses one point at seed 123456 by one f32 step, where the full tree is exact. I tried rounding the constant-endedlerponce instead of twice, and it got worse (9 misses). The test records it as open. Reading how the game compiles thatlerp, in the binary, is the next step.amplitude_corrected_multioctave_noisefrom the game form (AmplitudeCorrectedGame), since both score 26. Moving Nauvis to the game form is still its own change.Math.froundat every op. I did not run its code.Follow-ups this points at
cliff_elevation_nauvisstill do their own arithmetic in f64. The last Nauvis pixel's grass-1/grass-3 gap barely moved once its inputs were exact, so the tile scores are the next suspect.water_levelis narrowed where it is used, but the caller computes10 * log2(size)in f64. That is exact at the default size only.Checks
cargo test(fmw-noise): 535 passed after each commit.pnpm vp test, full suite, after each commit: green once the Nauvis tier-2 section was re-recorded.pnpm run verifyon the head: exit 0 in 6m40s on hammond.cargo denyskipped there (not installed); CI runs it.🤖 Generated with Claude Code
https://claude.ai/code/session_01Kd6o1cBoAGaJ1FoYPm6arC
Summary by CodeRabbit