Skip to content

Commit 0fa70bc

Browse files
committed
code clean up
1 parent bb4b072 commit 0fa70bc

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

PathPlanning/AStar/a_star.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
Nikos Kanargias ([email protected])
77
88
See Wikipedia article (https://en.wikipedia.org/wiki/A*_search_algorithm)
9-
See also code of Christian Careaga (http://code.activestate.com/recipes/578919-python-a-pathfinding-with-binary-heap/)
109
1110
"""
1211

@@ -98,8 +97,13 @@ def a_star_planning(sx, sy, gx, gy, ox, oy, reso, rr):
9897
if not verify_node(node, obmap, minx, miny, maxx, maxy):
9998
continue
10099

101-
if node.cost < node.cost or n_id not in openset:
102-
openset[n_id] = node # update or insert new node
100+
if n_id not in openset:
101+
openset[n_id] = node # Discover a new node
102+
103+
if node.cost >= node.cost:
104+
continue # this is not a better path
105+
106+
openset[n_id] = node # This path is the best unitl now. record it!
103107

104108
rx, ry = calc_fianl_path(ngoal, closedset, reso)
105109

0 commit comments

Comments
 (0)