Skip to content

A* returns a one-point path at the goal when the goal is unreachable #1509

Open

Description

@blessedefe4real

AStarPlanner.planning in PathPlanning/AStar/a_star.py does not signal failure when the goal cannot be reached. When the open set is exhausted the loop only breaks and then calls calc_final_path(goal_node, closed_set); the goal node's parent is still -1, so the result is [gx], [gy], a one-point "path" sitting on the goal. A caller cannot tell this apart from a real result.

Reproduce

from PathPlanning.AStar import a_star as m
m.show_animation = False

# square boundary 0..10 with an inner wall at x = 5
ox, oy = [], []
for i in range(11):
    ox += [0.0, 10.0, float(i), float(i), 5.0]
    oy += [float(i), float(i), 0.0, 10.0, float(i)]
planner = m.AStarPlanner(ox, oy, 1.0, 0.5)

print(planner.planning(2.0, 5.0, 8.0, 5.0))  # ([8.0], [5.0]) although no path exists

Expected

Return empty lists [], [] when no path exists, consistent with the proposed Dijkstra fix in #1418 and the BFS/DFS/bidirectional A* fixes in #1505, #1506 and #1507.

Tested on current master (61a8b0b), Python 3.13.

Activity

  1. dayvenhppg2 commented on Nov 14, 2026

    @dayvenhppg2

    The loop in AStarPlanner.planning should return empty lists immediately if the open_set is empty before reaching the goal, rather than proceeding to calc_final_path. You can implement this by checking if not open_set: inside the while loop, which mirrors the logic applied in the recent Dijkstra and BFS/DFS fixes. Adding this check prevents the function from incorrectly generating a path from the initial goal_node state when no valid traversal exists.

  2. blessed-maker commented on Nov 19, 2026

    @blessed-maker

    Thanks, agreed. That’s the approach in #1510: when open_set is empty, planning now returns [], [] right away instead of breaking into calc_final_path, which is the same idea as the BFS/DFS fixes. It includes a regression test with a walled-off goal, plus a check that start == goal still returns a single-point path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions