Repository navigation
Keep root costs and traversal consistent when adding destinations - #191
Merged
HexDecimal merged 5 commits intoOct 12, 2026
Merged
Conversation
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.
Adding a root after resolving a
Pathfinderupdates its distance but leaves its old predecessor, so routes through it can loop after resolving again. An added destination with a higher cost also overwrites a cheaper route.Update the distance and reset the predecessor only when the new root improves the current distance. Equal or worse roots retain the existing field, path and frontier. This keeps destination weights and traversal consistent.
Untouched main raises
Possible cyclic loop detected; the fix returns a valid route. For the weighted case, start with root(0, 0), resolve, then add(0, 2)with value 20. Previously its distance changes from 2 to 20 and routes terminate at this expensive root. Now its distance remains 2 and the cheaper route is preserved.The original 12 regressions cover 2D/3D grids, C/F order and root weights. The additional 64 cases cover partial/full resolution, negative/positive initial weights and lower/equal/higher new costs: 48 fail on the previous PR head, and all 64 pass after this update.
On three published Dragon Age maps, an independent multi-source Dijkstra reference verifies all 2,304 agent routes with competing destination costs. This corrects 44 wrong distance entries and 319 invalid-cost routes. The original 1,920 destination routes and all twelve ordinary control reports/hashes stay identical.
Validation after integrating current main: complete native
pytest --no-windowsuite passes 281 tests with 95 existing skips, using SDL's dummy audio backend on this host. All 76 root regressions and 14 merged lazy-goal cases pass. The preservation test takes its snapshot after the lazy path query, which can advance a partially resolved search. Changed-file project hooks and Mypy pass. Without the dummy backend the existing audio-device fixture reports no available device. Security-specific hooks were excluded from this non-security task. The prior graphical screenshot hang on unchanged main remains an existing local limitation; Windows/macOS and a complete graphical-suite pass are not claimed.This correction explicitly covers adding roots followed by resolution. Reconsidering an already settled lazy goal is handled separately in #192, which has now merged and is included in this branch. Native weighted-root and lazy-new-root game-map checks independently verify 4,608 routes on the combined source.