Skip to content

Aquilo: draw the wells' tile rewrite as its expected outcome (#586) - #605

Merged
wormeyman merged 2 commits into
mainfrom
aquilo-well-tile-effect-586
Dec 6, 2026
Merged

wormeyman merged 2 commits into
mainfrom
aquilo-well-tile-effect-586

Conversation

@wormeyman

@wormeyman wormeyman commented Dec 5, 2026 •

Copy link
Copy Markdown
Collaborator

Refs #586

What this does

Each Aquilo well's created_effect turns nearby water into snow and ice when the well is created. The real-surface views (all, resources, rocks) now draw the expected outcome of that rewrite:

  • Every water tile (ammoniacal-ocean, ammoniacal-ocean-2, brash-ice) in the well's 3 x 3 becomes snow-lumpy. The game does this with no randomness: a radius of 1.5 around the well's tile centre.
  • Outside the 3 x 3, every water tile with dx^2 + dy^2 <= 10 (squared distance between tile centres) becomes ice-rough.
  • Entities are still placed from the tiles before the rewrite, as the game does. Only the drawn tile changes.

The outer explosion is a cluster whose points come from the surface's own random generator, so a preview cannot reproduce it tile for tile. This PR draws its expected outcome, the same approach as tree removal. The issue stays open for that random part.

The rule lives in crates/fmw-noise/src/placement/aquilo_well_tiles.rs and is applied in real_surface_window into a new shown tile buffer.

How the rule was chosen

A new probe, scripts/probes/aquilo-well-tile-rewrite, runs Factorio 2.1.23 through factorio-oracle (with --factorio and --version, and a buildLine check) twice per seed: once as shipped, and once with created_effect removed from the three wells. Both runs placed the same wells at every seed. It was captured at four seeds: 123456, 2024, 31337 and 987654. Re-running seeds 123456 and 987654 wrote byte-identical files.

Among water tiles that only one well reaches, pooled over the four seeds:

  • every tile in the 3 x 3 became snow-lumpy (1,297 of 1,297), and no tile outside it did;
  • the share that changed falls off with straight-line distance: 90.3% at dx^2 + dy^2 = 4, 87.0% at 5, 75.2% at 8, 72.6% at 9, 66.3% at 10, 48.6% at 13, 34.5% at 16;
  • ice-rough is the most common result in every one of those rings, at every seed.

The ring keeps the distances where more than half the water changed. Leaving any one seed out of the pooling picks the same rule.

Three arms against the map a player gets

Wrong tiles by name over the 1024 x 1024 window, run on the game's own unrewritten tiles and wells (the_rule_against_four_real_surfaces):

seed (a) no rewrite (b) 3 x 3 only (c) 3 x 3 and ring, shipped (c) with a square ring instead
123456 2,756 2,186 1,493 1,669
2024 3,030 2,395 1,708 1,882
31337 2,588 2,054 1,450 1,624
987654 1,741 1,380 1,004 1,122

(c) beats (b) on every seed, with 27% to 32% fewer wrong tiles.

Which views change

  • all, resources and rocks at one tile per pixel. In all and resources each well paints over its own 3 x 3, so only the ring shows there. rocks shows both.
  • terrain is unchanged. It runs no entity generator, so it does not know where the wells are. The spec checks it still equals the game's run with no rewrite around every well and in the window's colour counts, at seeds 123456 and 987654.
  • Other zooms draw no entities and so no rewrite.

Frozen values that moved:

  • Aquilo parity spec, seed 123456: entity pixels are still 0 in all three views. Tile pixels against the game's rewritten tiles are 1,427 (all), 1,427 (resources) and 1,493 (rocks). With no rewrite drawn they would be 2,120, 2,120 and 2,756. Seed 987654 rocks: 1,004 (1,741 with none).
  • Fast counts against the real surface: 1,437, 1,430, 1,500. Fast's own cost on top of High is unchanged at 10, 3 and 7 pixels.
  • Fast seam count: 432 to 520.
  • Full preview PNG, tile against tile: 1,036 to 2,756.
  • 11 of the 14 aquilo:render tier-3 digests. The two terrain rows and "slider fluorine vent frequency | all" did not move.
  • engine.wasm is rebuilt: 648,605 to 650,689 bytes.
  • fmw-wasm's the_all_view_is_terrain_plus_both_overlays now treats the rewrite as part of the shared base of all, resources and rocks. A planted all without wells and a planted all without icebergs each turn it red.

Planted breaks

Each was run through the rebuilt module, the Rust rule tests and test/wasmAquiloRenderParity.spec.ts, then reverted:

break Rust spec
no 3 x 3 block red red in rocks only
no ring red red (18 tests)
block snow-patchy red red in rocks only
ring snow-patchy red red (17 tests)
ring ice-smooth red green
ring to 9 red red (18 tests)
ring to 13 red red (18 tests)
entities placed on the rewritten tiles green red (22 tests)

Stated gaps

  • ice-rough and ice-smooth share a map colour, so no pixel test can tell them apart. Only the Rust tests, which grade by tile name, catch an ice-smooth ring.
  • In the spec, the 3 x 3 block is graded by rocks alone, because all and resources paint the well over it.
  • The rule is calibrated on forced chunk requests. A paced game (Real-surface grades assume one chunk generation order; a player's map can differ #589) rewrites its own random tiles: 2,797 at seed 123456 against the forced 2,756.
  • Tiles two wells reach were left out of the calibration and get the same rule.

Cost

WASM under Node, the 1024 window as 64 tiles of 128 summed on one thread, High, median of 7 interleaved runs, main against this branch: all 5,409 vs 5,478 ms, resources 5,474 vs 5,475 ms, rocks 5,482 vs 5,411 ms. The ranges overlap in every row, and terrain, whose code did not change, moved more (2,676 vs 2,882 ms), so the differences are noise.

Verify

pnpm run verify exits 0 locally on this commit, every phase run: vp check, check:vue, vp test (121 files, 1,532 passed, 3 skipped), preview:test (27 passed), and verify:rust (fmt, clippy, doc, cargo test, the anti-vacuity check, zero dependencies, engine.wasm matches its source, cargo deny).

docs/rust-wasm-port.md has the full tables in a new section, "Aquilo's well tile rewrite".

🤖 Generated with Claude Code

https://claude.ai/code/session_01Kd6o1d3a5zQDRDok3ePdHh

Summary by CodeRabbit

  • New Features
    • Aquilo render views now show the expected terrain changes around resource wells, including snow-like tiles within each well’s immediate area and rough-ice tiles nearby. Terrain-only views remain unchanged.
  • Bug Fixes
    • Updated Aquilo previews and render output to reflect well-related terrain changes more accurately.
  • Tests
    • Expanded render checks across multiple map seeds and views to verify terrain and well visuals.
  • Documentation
    • Updated Aquilo rendering and parity guidance to describe the visible terrain changes.

Each Aquilo well's created_effect turns nearby water into snow and ice.
The inner explosion is fixed: snow-lumpy within radius 1.5 of the well's
tile centre, which is the well's 3 x 3. The outer one is a cluster drawn
from the surface's random generator, so a preview cannot reproduce it
exactly. The real-surface views (all, resources, rocks) now draw its
expected outcome. Water tiles in the 3 x 3 become snow-lumpy, and water
tiles at dx^2 + dy^2 <= 10 become ice-rough. Those are the rings where
over half the water changed, pooled over four seeds, and ice-rough is the
most common result in each. Entities are still placed from the tiles
before the rewrite.

Calibrated on a new probe, scripts/probes/aquilo-well-tile-rewrite. At
four seeds it captures the game run as shipped and with created_effect
removed, on 2.1.23. Tile errors against the map a player gets, by name,
over the 1024 window:

  seed     no rewrite   3x3 only   3x3 + ring (shipped)
  123456   2756         2186       1493
  2024     3030         2395       1708
  31337    2588         2054       1450
  987654   1741         1380       1004

A square ring scores worse on every seed (1669, 1882, 1624, 1122).
Leaving any one seed out picks the same rule. Render cost is unchanged
within noise.

The rule's tests freeze every row above plus six changed rules. The
Aquilo parity spec now grades entity pixels at 0 and tile pixels at a
frozen count against the game's rewritten tiles. It also checks that
the terrain view equals the run with no rewrite. The fmw-wasm "all is
base plus both overlays" test now treats the rewrite as part of the
shared base. engine.wasm is rebuilt, and the tier-3 digests, Fast counts
and seam count are re-frozen. docs/rust-wasm-port.md has the tables,
the planted breaks and the two stated gaps: ice-smooth shares
ice-rough's colour, and the 3 x 3 is graded only in rocks.

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

coderabbitai Bot commented Dec 5, 2026 •

Copy link
Copy Markdown

Explain Change →

Important

Review skipped

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: 1fdf0bb9-e775-4f51-8c15-128be607be7c
Commits

Reviewing files that changed from the base of the PR and between 7adc49d and 0c37ad0.

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

This change models the expected tile rewrite around Aquilo resource wells and applies it to entity views after entity placement. Captured Factorio surfaces support rule tests and render-parity comparisons, which distinguish tile mismatches from entity mismatches.

Changes: Aquilo well tile rewrite

Layer / File(s) Summary
Capture and calibrate rewrite data
scripts/probes/aquilo-well-tile-rewrite/*, test/fixtures/oracle-aquilo-well-tile-rewrite.*.json, test/fixtures/PROVENANCE.json
Capture and calibration scripts compare shipped and stripped well effects and report tile changes across four seeds. The captured fixtures record the compared tiles and well neighborhoods.
Define and validate the rewrite
crates/fmw-noise/src/placement/aquilo_well_tiles.rs, crates/fmw-noise/src/placement/mod.rs, crates/fmw-noise/src/fixtures.rs, crates/fmw-noise/src/fixtures/aquilo_well_tiles.rs
The rewrite paints eligible tiles in each well’s 3×3 block and within squared distance 10. Tests validate the rule against captured surfaces and compare alternative rule settings.
Store and render post-rewrite tiles
crates/fmw-noise/src/placement/aquilo.rs, crates/fmw-wasm/src/render.rs, crates/fmw-wasm/src/lib.rs, test/fixtures/tier3-render-checksums.json
Aquilo surface windows store corrected tiles and post-rewrite shown tiles. Entity views use shown tiles, and render tests check the revised overlay behavior and checksums.
Check render parity and document results
test/wasmAquiloRenderParity.spec.ts, docs/rust-wasm-port.md, scripts/probes/aquilo-real-surface-entities/README.md
Parity tests compare views against rewrite fixtures and separately count tile and entity mismatches. Documentation records the rewrite rule, measurements, and updated comparisons.

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

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant real_surface_window
  participant rewrite
  participant AquiloSurfaceWindow
  participant AquiloEntityRenderer
  real_surface_window->>rewrite: Pass placed wells and corrected-tile lookup
  rewrite-->>real_surface_window: Return tile changes
  real_surface_window->>AquiloSurfaceWindow: Store corrected and shown tiles
  AquiloEntityRenderer->>AquiloSurfaceWindow: Read shown_tile
Loading

Possibly related issues

  • Issue 586 asks for the expected snow and ice from well effects in the preview. This change adds the 3×3 snow-lumpy block and ice-rough ring to the modeled views.
  • Issue 400 tracks per-planet render parity, including Aquilo. This change updates Aquilo render output and parity comparisons.

Possibly related PRs

Merge Risk: Minimal · previous review 7adc4 · 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 the main change: the Aquilo wells' tile rewrite is now drawn in the preview as its expected outcome. The raw summary confirms this: a new WELL_TILE_REWRITE rule, shown_tile lookups, an…
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 the main change: the Aquilo wells' tile rewrite is now drawn in the preview as its expected outcome. The raw summary confirms this: a new WELL_TILE_REWRITE rule, shown_tile lookups, and render changes for the all, resources, and rocks views. The title's '(#586)' reference matches the README note about #586, while the objectives mention PR #605. That mismatch does not change the title's relevance to the changeset.

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: 994b8265-8ae8-47f0-98e7-3288afea6695
Commits

Reviewing files that changed from the base of the PR and between 63d9410 and 7adc49d.

Files ignored due to path filters: 1

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

  • crates/fmw-noise/src/fixtures.rs
  • crates/fmw-noise/src/fixtures/aquilo_well_tiles.rs
  • crates/fmw-noise/src/placement/aquilo.rs
  • crates/fmw-noise/src/placement/aquilo_well_tiles.rs
  • crates/fmw-noise/src/placement/mod.rs
  • crates/fmw-wasm/src/lib.rs
  • crates/fmw-wasm/src/render.rs
  • docs/rust-wasm-port.md
  • scripts/probes/aquilo-real-surface-entities/README.md
  • scripts/probes/aquilo-well-tile-rewrite/README.md
  • scripts/probes/aquilo-well-tile-rewrite/calibrate.ts
  • scripts/probes/aquilo-well-tile-rewrite/capture.ts
  • test/fixtures/PROVENANCE.json
  • test/fixtures/oracle-aquilo-well-tile-rewrite.seed123456.json
  • test/fixtures/oracle-aquilo-well-tile-rewrite.seed2024.json
  • test/fixtures/oracle-aquilo-well-tile-rewrite.seed31337.json
  • test/fixtures/oracle-aquilo-well-tile-rewrite.seed987654.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.

@claude

claude Bot commented Dec 5, 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 45eef1b into main Dec 6, 2026
16 checks passed
@wormeyman
wormeyman deleted the aquilo-well-tile-effect-586 branch December 6, 2026 03:32
wormeyman added a commit that referenced this pull request Dec 6, 2026
Take main's Aquilo well-tile rewrite (#605) alongside the Gleba tower
view. Only engine.wasm conflicted; it is rebuilt from the merged sources
with scripts/build-wasm.sh (sha256 0e10b70a..., 664,557 bytes). View
codes do not collide (VIEW_TOWER_SCORES stays 13).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kd6o1d3a5zQDRDok3ePdHh
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