Skip to content

Fix wrap path heuristic for out-of-board cells - #1

Open
kvnloo wants to merge 1 commit into
xt4d:mainfrom
kvnloo:fix/wrap-path-heuristic
Open

Fix wrap path heuristic for out-of-board cells#1
kvnloo wants to merge 1 commit into
xt4d:mainfrom
kvnloo:fix/wrap-path-heuristic

Conversation

@kvnloo

@kvnloo kvnloo commented Sep 1, 2026

Copy link
Copy Markdown

Summary

  • GridPathPlanner wrap distance used min(|d|, size-|d|) without reducing d modulo the board, so A* heuristic could go negative when cells were outside [0, size).
  • Reduce the axis delta modulo the period first so torus distance stays in [0, size/2].
  • Pin with GridPathPlanner.test.js.

Test plan

  • node --experimental-default-type=module --test gameblocks/modules/behavior/GridPathPlanner.test.js

Independent verify: fail-then-pass h(0→15) -5 → 5 on SHA e181193a873bc55c8092ba2bac24c2656cdd412a.

Modulo the axis delta before torus distance so A* wrap cost stays non-negative.
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