You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A* returns a one-point path at the goal when the goal is unreachable #1509
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
fromPathPlanning.AStarimporta_starasmm.show_animation=False# square boundary 0..10 with an inner wall at x = 5ox, oy= [], []
foriinrange(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.
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.
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.
Activity
dayvenhppg2 commentedon Nov 14, 2026
The loop in
AStarPlanner.planningshould return empty lists immediately if theopen_setis empty before reaching the goal, rather than proceeding tocalc_final_path. You can implement this by checkingif not open_set:inside thewhileloop, 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 initialgoal_nodestate when no valid traversal exists.blessed-maker commentedon Nov 19, 2026
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.