Skip to content

Commit 0fbcb38

Browse files
committed
Fix heap lookup
1 parent 2939c6a commit 0fbcb38

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

algorithms/a_star_path_finding.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def process(self):
115115
heapq.heappush(self.op, (self.start.f, self.start))
116116
while len(self.op):
117117
# pop cell from heap queue
118-
h, cell = heapq.heappop(self.op)
118+
f, cell = heapq.heappop(self.op)
119119
# add cell to closed list so we don't process it twice
120120
self.cl.add(cell)
121121
# if ending cell, display found path
@@ -126,7 +126,7 @@ def process(self):
126126
adj_cells = self.get_adjacent_cells(cell)
127127
for c in adj_cells:
128128
if c.reachable and c not in self.cl:
129-
if c in self.op:
129+
if (c.f, c) in self.op:
130130
# if adj cell in open list, check if current path is
131131
# better than the one previously found
132132
# for this adj cell.

0 commit comments

Comments
 (0)