Put the pumpjack pipe on the corner Factorio 2.1 actually uses - #90
Merged
Conversation
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
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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.
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. Prototypepositionsis 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.TerminalOffsetsMatchTheFactorioOutputCornersnow pins all four offsets to the committed oracle fixture. The next time Factorio moves a corner, a test fails and namesHelpers.cs, instead of plans quietly coming out wrong for a year.Everything else follows from the geometry
CleanBlueprintgives 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.PlanUndergroundPipesfixtures 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.BlueprintsWithIsolatedAreas. Its isolated area is now reachable, and the planner returns a valid plan for it withValidateSolutionon. It is no longer an example of that failure. Two others still are.FbeOriginalFallsBackToFbeWhenLeftoverPumpsCannotConnectgot 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.CountsNoRotatedPumpjackswas re-stamped so its pumpjacks again face the way the planner picks, which is what makes "no rotated pumpjacks" the right expectation.YieldsAlternateSolutionstook a field that still ties.What it costs
Heat routing does worse. On the small list, which this change does not touch:
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
UseLuaSettings=true.src/luais regenerated and verified withtools/check-lua.sh, which syntax-checks withluac5.2.4 and runs the planner.🤖 Generated with Claude Code
https://claude.ai/code/session_01UEteUvDzR5h4jEcowhm799