Skip to content

Put the pumpjack pipe on the corner Factorio 2.1 actually uses - #90

Merged
wormeyman merged 1 commit into
mainfrom
fix/pumpjack-terminals-21-v2
Aug 17, 2026
Merged

Put the pumpjack pipe on the corner Factorio 2.1 actually uses#90
wormeyman merged 1 commit into
mainfrom
fix/pumpjack-terminals-21-v2

Conversation

@wormeyman

Copy link
Copy Markdown
Collaborator

Fixes #81.

Factorio 2.1 gave the pumpjack four distinct output corners. Factorio 2.0 had only two: east reused north's corner, and west reused south's (FFF #442). The planner still hardcoded the 2.0 pair, so every east-facing and west-facing pumpjack had its pipe attached to the opposite corner from where the game outputs.

This is a second, independent cause of the mis-rotated pumpjack reports. The direction encoding bug fixed in #77 was the first. This one is older and was not introduced by that work.

             2.0.77    2.1.14
north        (1,-2)    (1,-2)
east         (2,-1)    (2,1)     <- moved
south        (-1,2)    (-1,2)
west         (-2,1)    (-2,-1)   <- moved

The numbers are measured, not derived

Issue #81 inferred these from prototype data and said so. They are now read from the running game instead.

A probe mod places pumpjacks in all four rotations and reads PipeConnection.target_position, which is the tile the connecting pipe actually occupies. Prototype positions is a different thing: it is the connection point inside the entity, and the pipe sits one tile further out. Deriving one from the other means trusting a convention, so the probe reads the answer directly.

It was run against real 2.0.77 and 2.1.14 installs. The 2.0.77 row reproduces the numbers the planner already had. That is what makes it believable about 2.1.14 - a probe that only runs against the version you care about cannot tell you it is working.

FactorioOracleTest.TerminalOffsetsMatchTheFactorioOutputCorners now pins all four offsets to the committed oracle fixture. The next time Factorio moves a corner, a test fails and names Helpers.cs, instead of plans quietly coming out wrong for a year.

Everything else follows from the geometry

  • The corpus is re-normalized. CleanBlueprint gives each pumpjack the lowest-numbered direction whose terminal is unblocked, and 16 big-list blueprints answer that differently now. Blueprint counts are unchanged at 1147 and 61, and the small list did not move at all.
  • Four PlanUndergroundPipes fixtures place a pumpjack so its terminal lands on, beside, or at the end of a pipe run. Each pumpjack or run was moved so the terminal lands where the scenario needs it again.
  • One blueprint left BlueprintsWithIsolatedAreas. Its isolated area is now reachable, and the planner returns a valid plan for it with ValidateSolution on. It is no longer an example of that failure. Two others still are.
  • FbeOriginalFallsBackToFbeWhenLeftoverPumpsCannotConnect got a new blueprint. The old one stopped reaching that fallback. Big-list index 827 still does, found by making the branch throw and scanning both corpus lists for the hit.
  • CountsNoRotatedPumpjacks was re-stamped so its pumpjacks again face the way the planner picks, which is what makes "no rotated pumpjacks" the right expectation. YieldsAlternateSolutions took a field that still ties.

What it costs

Heat routing does worse. On the small list, which this change does not touch:

Before After
Fields needing zero pumpjack drops 35 of 61 34 of 61
Pumpjacks dropped in total 51 64

One field also now drops a pumpjack with beacons on that heat-only keeps, breaking an invariant that used to hold. That case is pinned to its known-bad numbers rather than skipped, so fixing the router fails the test and points at the comment. Filed as #89.

The planner is now solving the real 2.1 problem, and on this corpus that problem is harder. Beacon and pipe quality barely moved: average beacon effects 110.4 -> 109.7, pipes 46.3 -> 46.8.

Checks

  • 4302 tests pass under the default settings and under UseLuaSettings=true.
  • src/lua is regenerated and verified with tools/check-lua.sh, which syntax-checks with luac 5.2.4 and runs the planner.
  • A second full test run leaves the tree clean, so no Verify snapshot drifted.

🤖 Generated with Claude Code

https://claude.ai/code/session_01UEteUvDzR5h4jEcowhm799

Factorio 2.1 gave the pumpjack four distinct output corners where 2.0 had
two: east reused north's corner and west reused south's (FFF #442). The
planner still hardcoded the 2.0 pair, so every east-facing and west-facing
pumpjack got its pipe attached to the opposite corner from the one the game
outputs on. This is issue #81, and it is a second, independent cause of the
mis-rotated pumpjack reports, separate from the direction encoding fixed
in #77.

The offsets are measured, not derived. A probe mod placed pumpjacks in all
four rotations and read PipeConnection.target_position - the tile the
connecting pipe actually occupies - out of two running games. It reproduces
the numbers the planner already had on 2.0.77 before being believed about
2.1.14, which is what makes the new pair trustworthy.

FactorioOracleTest.TerminalOffsetsMatchTheFactorioOutputCorners pins the
four offsets to the committed oracle fixture, so a future corner move fails
a test naming Helpers.cs instead of silently shipping wrong plans.

Everything else here follows from the geometry:

- The corpus is re-normalized. CleanBlueprint gives each pumpjack the
  lowest-numbered direction whose terminal is unblocked, and 16 big-list
  blueprints answer that differently now. Counts are unchanged at 1147 and
  61, and the small list did not move.
- Four PlanUndergroundPipes fixtures place a pumpjack so its terminal lands
  on, beside, or at the end of a pipe run. Each was moved so the terminal
  lands where the scenario needs it again.
- One blueprint left BlueprintsWithIsolatedAreas: its isolated area is now
  reachable and the planner returns a valid plan for it, checked with
  ValidateSolution on.
- FbeOriginalFallsBackToFbeWhenLeftoverPumpsCannotConnect got a new
  blueprint. The old one stopped reaching that fallback; big-list index 827
  still does, found by making the branch throw and scanning both lists.
- CountsNoRotatedPumpjacks was re-stamped so its pumpjacks again face the
  way the planner picks, and YieldsAlternateSolutions took a field that
  still ties.

Heat routing pays for this. On the unchanged small list, fields needing zero
pumpjack drops go 35 -> 34 and total drops 51 -> 64, and one field now drops
a pumpjack with beacons on that heat-only keeps. That case is pinned rather
than skipped so fixing it fails the test. Tracked as #89.

4302 tests pass under both the default settings and UseLuaSettings=true. The
Lua is regenerated and checked with tools/check-lua.sh.

Fixes #81

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UEteUvDzR5h4jEcowhm799
@wormeyman
wormeyman merged commit a9ba309 into main Aug 17, 2026
5 checks passed
@wormeyman
wormeyman deleted the fix/pumpjack-terminals-21-v2 branch August 17, 2026 23:02
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.

Pumpjack terminal offsets likely wrong for East and West on Factorio 2.1

1 participant