Skip to content

Aquilo: terrain matches a real surface through tile correction, at 1.3x cost (#454) - #562

Merged
wormeyman merged 2 commits into
mainfrom
aquilo/real-surface-tiles
Nov 27, 2026
Merged

wormeyman merged 2 commits into
mainfrom
aquilo/real-surface-tiles

Conversation

@wormeyman

@wormeyman wormeyman commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Aquilo's terrain now matches a real Aquilo surface at every tile, where before it matched only the game's map preview. Tile correction alone closes the gap. A shared change to correction.rs cuts the render cost from about 3x to about 1.3x.

Against a real surface

The ground truth is a new fixture, oracle-aquilo-real-surface.seed123456.json. It was captured on 2.1.23 at seed 123456 (surface seed 3111923328), over tiles -128..127, with the three resource levers at size 0 and the terrain-only mod. It has a PROVENANCE entry.

by name by colour
raw argmax (what the preview draws) 551 531
with tile correction 0 0

More checks, all exact: two uncommitted 1024x1024 captures (1,048,576 tiles each), and the land mask of the existing 640x640 oracle-aquilo-surface fixture (now a committed test; 172 tiles were wrong raw). The 21% of differing pixels whose preview colour no real neighbour had are explained by correction too, because the walk spreads.

  • Layers come from the game at runtime: oceans 67, brash ice 80, ice 194 and 195, snows 196 to 199. They are asserted against the fixture.
  • No ties: 0 tied top scores over 1,327,104 tiles around spawn (a committed test covers the window plus a 64-tile margin).
  • No allowed_neighbors on any Aquilo tile.

The render cost

correction.rs gains correct_window, a shared entry point (raw-tile closure, layers, origin, size, margin), with two changes that are exact by construction:

  1. Raw tiles are read lazily. Area evaluates a tile only when the pass first reads it, so the outer ring of margin chunks costs only the band the walks reach.
  2. No-op walks are skipped. A walk whose seed sits in a 3x3 block of one id changes nothing, so it is skipped. The test is on ids, not layers, so it stays exact under an allowed_neighbors rule, whose check comes after n == c.

Aquilo also keeps the fields correction already evaluated, so its entity pass reuses them (KeptFields, capped at 64 chunks). Gleba now uses correct_window too.

app default view (1024 all) Node, 64 tiles summed headless Chrome, wall
raw argmax, before this PR 2,236 ms 590 ms
first correction wiring 6,645 ms 1,691 ms
this PR 2,920 ms (1.31x) 750 ms (1.27x)

The Node figures are a median of 7 interleaved runs; the Chrome figures, a median of 9 Generate clicks with dev mode on. Both were taken on a loaded machine.

Output unchanged by the cost work: 52 requests across all four views, both lever sets, six windows and three zooms, plus two Gleba windows, are byte-identical to the first wiring. New unit tests check lazy against eager reads, and that skipping changes nothing, on random grids.

What moved

  • Terrain PNG (now a reference): 0 -> 718. In the 256 window, the PNG differs from our render exactly where it differs from the real surface (531, asserted).
  • Full PNG: 3 -> 1,067. These are tile pixels plus the same 3 iceberg edge pixels; entity counts are unchanged.
  • Levers-neutral control: 13,194 -> 13,707.
  • aquilo:render: 13 of 14 rows moved. Every moved pixel is a tile, and equals the new terrain view.
  • Tier 2: no fold moved.

Planted breaks

  • No correction in the render: 15 of 27 tests red, and the real surface goes 0 -> 531.
  • Brash-ice layer set to 67: 0 -> 160.
  • Margin 0: the tiled count goes 0 -> 45.

What users see

The app opens Aquilo at 1 tile per pixel in all, so correction applies by default: the real coastline and ice edges, with the wells and icebergs drawn by the preview's rule on top. Other zooms draw the raw argmax. Wells and icebergs still test the raw tile, so #553 is unchanged, but our land now equals the land the entity replay reads.

Gate

pnpm run verify:lint, the full pnpm vp test (1,360 passed) and scripts/verify-rust.sh pass locally. cargo deny is not installed on hammond; CI runs it.

Refs #454.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Kd6o1dTdCEZ5JSjytamwMZ

Summary by CodeRabbit

  • New Features
    • Aquilo terrain now uses tile correction in supported tile-aligned views, improving agreement with in-game terrain and land/water boundaries.
    • Entity rendering can reuse terrain evaluations for eligible views.
  • Documentation
    • Aquilo terrain notes now describe correction behavior, margin requirements, and comparison results against captured in-game surfaces.

wormeyman and others added 2 commits November 26, 2026 17:39
At one tile per pixel on a whole-tile origin the Aquilo render now runs the
game's tile correction after the argmax, as Gleba's does, with Aquilo's nine
layers read from the game. correction.rs is unchanged.

- New fixture oracle-aquilo-real-surface.seed123456.json (2.1.23, -128..127,
  levers off), from the Gleba probe, which now takes FMW_PLANET.
- Real surface: 531 pixels (551 tiles by name) before, 0 after. Two
  uncommitted 1024 real surfaces (levers off, and neutral with every entity
  autoplace removed) also match at every tile, and so does the land mask of
  oracle-aquilo-surface (172 wrong raw).
- No ties in 1,327,104 tiles; no Aquilo tile has allowed_neighbors.
- Preview PNG tests become references: terrain 0 -> 718, full PNG
  3 -> 1,067 (1,064 tile pixels, all where the real surface differs).
  13 of 14 aquilo:render digests moved; every moved pixel is terrain.
- About 3x render cost (256 terrain 64 -> 189 ms; default 1024 all view as
  64 tiles 2.2 -> 6.6 s of CPU).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kd6o1dTdCEZ5JSjytamwMZ
The Aquilo render's tile correction cost about 3x the raw argmax. Three
changes bring the app's default view (1024 all, 64 worker tiles of 128)
to about 1.3x without changing an output byte:

- correction.rs gains correct_window: the shared entry point a renderer
  calls with a raw-tile closure. It reads raw tiles lazily, so the outer
  ring of chunks costs only the band the walks reach. Gleba uses it too.
- The scan skips a walk whose seed sits in a 3x3 block of one id; such a
  walk changes and queues nothing.
- The Aquilo render keeps the fields correction evaluated for the
  window's chunks (KeptFields) and the entity generator reuses them.

Default view, map seed 123456: WASM under Node 2,236 ms raw, 6,645 ms
first wiring, 2,920 ms now; headless Chrome wall 590, 1,691, 750 ms.

Output checked byte for byte against the previous module on 52 Aquilo
and Gleba requests and the tiled and whole 1024 all view. Unit tests pin
both correction changes on random grids. Real-surface counts stay 0.

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

claude Bot commented Nov 27, 2026

Copy link
Copy Markdown

Code review

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

@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Aquilo rendering now applies tile correction to supported whole-tile windows. Shared lazy correction supports window-based processing, while Aquilo placement can reuse evaluated fields. The change also adds real-surface fixtures, capture support, and render parity checks.

Changes: Terrain correction and real-surface validation

Layer / File(s) Summary
Lazy window correction
crates/fmw-noise/src/tiles/correction.rs
Area can load and cache tiles on demand. The correction code adds correct_window and uses lazy reads during chunk correction. Tests compare lazy and eager results and check uniform-seed skipping.
Tile stack and field adapters
crates/fmw-noise/src/tiles/aquilo_catalog.rs, crates/fmw-noise/src/expressions/aquilo_stack.rs, crates/fmw-noise/src/expressions/gleba_stack.rs, crates/fmw-noise/src/placement/aquilo.rs
Aquilo tile layers and corrected-window methods support the correction path. Gleba delegates window correction to correct_window. Aquilo chunk inputs can reuse retained fields.
Aquilo rendering and entity field reuse
crates/fmw-wasm/src/render.rs
Eligible one-tile-per-pixel Aquilo requests render corrected tiles. For entity views covering at most 64 chunks, the renderer can retain fields and pass them to AquiloEntities.
Real-surface fixtures and validation
crates/fmw-noise/src/fixtures/*, scripts/probes/gleba-real-surface/*, test/fixtures/PROVENANCE.json, test/fixtures/oracle-aquilo-real-surface.seed123456.json, test/fixtures/tier3-render-checksums.json, test/wasmAquiloRenderParity.spec.ts, docs/noise/aquilo-NOTES.md, docs/rust-wasm-port.md
The capture script supports Gleba and Aquilo. Fixture tests compare corrected terrain with captured surfaces, and render parity checks distinguish real-surface results from preview-image differences. The documentation records correction measurements and checksums are updated.

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant Renderer as render_aquilo
  participant Stack as AquiloStack
  participant Correction as correct_window
  participant Entities as AquiloEntities
  Renderer->>Stack: corrected_tiles_keeping window and margin
  Stack->>Correction: raw tile callback, layers, window, margin
  Correction-->>Stack: corrected tile IDs
  Stack-->>Renderer: corrected tiles and optional KeptFields
  Renderer->>Entities: reusing stack and retained fields
Loading

Possibly related issues

Possibly related PRs

Merge Risk: Minimal · up to 3526d · assessed changes only

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

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names Aquilo terrain matching a real surface through tile correction, with a cost figure of 1.3x. The changeset adds Aquilo tile correction (correction.rs, aquilo_stack.rs), real-surface fix…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names Aquilo terrain matching a real surface through tile correction, with a cost figure of 1.3x. The changeset adds Aquilo tile correction (correction.rs, aquilo_stack.rs), real-surface fixtures and tests, and the lazy correct_window path that the 1.3x cost figure refers to. The title covers the main change. The '(#454)' suffix is a PR reference and does not affect relevance.

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: 4a464b02-d6bc-4618-b756-f9b5bdb0ee2b
Commits

Reviewing files that changed from the base of the PR and between 915d3af and 3526dbf.

Files ignored due to path filters: 1

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

  • crates/fmw-noise/src/expressions/aquilo_stack.rs
  • crates/fmw-noise/src/expressions/gleba_stack.rs
  • crates/fmw-noise/src/fixtures.rs
  • crates/fmw-noise/src/fixtures/aquilo_real_surface.rs
  • crates/fmw-noise/src/placement/aquilo.rs
  • crates/fmw-noise/src/tiles/aquilo_catalog.rs
  • crates/fmw-noise/src/tiles/correction.rs
  • crates/fmw-wasm/src/render.rs
  • docs/noise/aquilo-NOTES.md
  • docs/rust-wasm-port.md
  • scripts/probes/gleba-real-surface/README.md
  • scripts/probes/gleba-real-surface/capture.ts
  • test/fixtures/PROVENANCE.json
  • test/fixtures/oracle-aquilo-real-surface.seed123456.json
  • test/fixtures/tier3-render-checksums.json
  • test/wasmAquiloRenderParity.spec.ts

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

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