Skip to content

Fix: price horizontal water moves at the water cost#11

Open
XaXayo12 wants to merge 1 commit into
Minecraft-Pathfinding:2026-rewritefrom
XaXayo12:fix-liquid-cost
Open

Fix: price horizontal water moves at the water cost#11
XaXayo12 wants to merge 1 commit into
Minecraft-Pathfinding:2026-rewritefrom
XaXayo12:fix-liquid-cost

Conversation

@XaXayo12

Copy link
Copy Markdown

Addresses the chatgpt-codex review note on #8.

Bug: Forward/Diagonal seeded the move with travelCost() at land speed and then added a flat liquidCost (default WATER - WALK). With sprinting on (the default), a one-block water move came to SPRINT + (WATER-WALK)8.02t instead of the intended 9.09t, and the flat add doesn't scale, so diagonal water moves were undercharged more. A* could then prefer water because it was priced too cheaply.

Fix: travelCost(blocks, inLiquid) returns WALK_ONE_IN_WATER_COST * blocks when in liquid (you swim — no sprint/walk), which is correct and scales with distance. Forward and Diagonal pass inLiquid and drop the flat add. Vertical providers (jump/drop/up/down) are unchanged.

Now a 1-block water move costs exactly WALK_ONE_IN_WATER_COST (9.091), and a diagonal WALK_ONE_IN_WATER_COST * √2.

Verified: npm run build + npx ts-standard -y clean, npm test 31/31.

…+ flat add)

Review catch (chatgpt-codex): Forward/Diagonal seeded the move with travelCost()
at land speed and then added a flat liquidCost. With sprinting on (the default) a
one-block water move came to ~8.02 ticks instead of the 9.09 water cost, and the
flat add did not scale, so diagonal water moves were undercharged even more.
Paths could prefer water because it was priced too cheaply.

travelCost(blocks, inLiquid) now returns WALK_ONE_IN_WATER_COST * blocks when in
liquid (you swim, can't sprint/walk), which is correct and scales with distance.
Forward and Diagonal pass inLiquid and no longer add the flat liquidCost. The
vertical providers (jump/drop/up/down) are unchanged.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

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