Skip to content

Fix Greedy Best-First path reconstruction for reached and unreachable goals - #1485

Open
huxiaoyi-ovo wants to merge 3 commits into
AtsushiSakai:masterfrom
huxiaoyi-ovo:fix/greedy-search-path-reconstruction
Open

huxiaoyi-ovo wants to merge 3 commits into
AtsushiSakai:masterfrom
huxiaoyi-ovo:fix/greedy-search-path-reconstruction

Conversation

@huxiaoyi-ovo

Copy link
Copy Markdown

Summary

Greedy Best-First Search currently mishandles two outcomes in planning():

  1. Unreachable goal: when open_set is exhausted, the method still calls path reconstruction. It inserts the last expanded node under the goal's unset parent index (-1), returning a fabricated path that includes the unreachable goal.
  2. Reached goal: the reconstruction setup injects the reached goal node into its parent's closed_set entry, then adds that goal node a second time to the returned coordinates.

Fix

  • Return ([], []) when the search frontier is empty.
  • On success, reconstruct the path directly from the reached node via its existing parent pointers.
  • Preserve the existing goal-to-start path ordering, planning interface, obstacle checks, and search strategy.

Regression tests

  • A bounded grid split by a full wall returns an empty path for an unreachable goal.
  • An adjacent reachable goal returns [(2, 2), (1, 2)] exactly, without repeating the goal.
  • A coincident start and goal returns a single waypoint.

Changes are limited to the Greedy Best-First planner and its test file. No new dependencies.

See fork-only cross-platform CI validation for Linux, macOS, Windows and CodeQL checks.

AI disclosure: ChatGPT assisted with source analysis, implementation, and regression tests.

@huxiaoyi-ovo
huxiaoyi-ovo marked this pull request as ready for review October 29, 2026 09:14

This branch has not been deployed

No deployments
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