Skip to content

Fix bidirectional BFS path reconstruction for empty and meeting paths - #1486

Open
huxiaoyi-ovo wants to merge 2 commits into
AtsushiSakai:masterfrom
huxiaoyi-ovo:fix/bidirectional-bfs-path-reconstruction
Open

huxiaoyi-ovo wants to merge 2 commits into
AtsushiSakai:masterfrom
huxiaoyi-ovo:fix/bidirectional-bfs-path-reconstruction

Conversation

@huxiaoyi-ovo

Copy link
Copy Markdown

Summary

The bidirectional breadth-first planner reconstructs paths from both search trees, but three cases are mishandled:

  • No path: exhausted search frontiers leave both meeting nodes as None, yet reconstruction is still attempted, raising an exception instead of returning an empty path.
  • Start equals goal: reconstruction indexes closed_set[-1] for the root node, raising KeyError.
  • Successful path: both search halves include the meeting cell, so concatenation duplicates that waypoint.

Fix

Reconstruct each half directly using its existing parent pointers. Return ([], []) when no meeting point was found, and include the shared meeting waypoint only once. The search order, collision checks, grid representation, and public planning() signature remain unchanged.

Regression tests

A new test module covers:

  1. An unreachable goal separated by an obstacle wall.
  2. An adjacent goal, with each waypoint appearing exactly once.
  3. Coincident start and goal, returning one waypoint.
  4. A longer reachable route with contiguous steps and no repeated meeting cell.

Two files changed. No new dependencies.

Cross-platform CI validation is running on the fork.

AI disclosure: ChatGPT assisted with code analysis, the fix, and regression tests.

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

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