fixes
This commit is contained in:
parent
76f78b9e58
commit
2c258fb6d5
@ -38,7 +38,7 @@ class Environment:
|
||||
for field in row:
|
||||
field.draw()
|
||||
self.grid.draw_grid()
|
||||
# self.astar.draw_path(self.window)
|
||||
self.astar.draw_path(self.window)
|
||||
pygame.display.flip()
|
||||
|
||||
def update_all_elements(self):
|
||||
|
@ -23,11 +23,11 @@ class Min_heap:
|
||||
def heapify(self, i):
|
||||
l = self.left(i)
|
||||
r = self.right(i)
|
||||
if l < len(self.items) - 1 and self.items[l] < self.items[i]:
|
||||
if l < len(self.items) and self.items[l] < self.items[i]:
|
||||
smallest = l
|
||||
else:
|
||||
smallest = i
|
||||
if r < len(self.items) - 1 and self.items[r] < self.items[smallest]:
|
||||
if r < len(self.items) and self.items[r] < self.items[smallest]:
|
||||
smallest = r
|
||||
if smallest != i:
|
||||
self.items[i], self.items[smallest] = self.items[smallest], self.items[i]
|
||||
@ -51,6 +51,7 @@ class Min_heap:
|
||||
print("Nowy klucz wiekszy od klucza aktualnego!")
|
||||
return
|
||||
self.items[index] = item
|
||||
self.items[index].heap_index = index
|
||||
while index > 0 and self.items[self.parent(index)] > self.items[index]:
|
||||
self.items[index], self.items[self.parent(
|
||||
index)] = self.items[self.parent(index)], self.items[index]
|
||||
@ -61,8 +62,9 @@ class Min_heap:
|
||||
def insert(self, item):
|
||||
temp_node = Node(State(0,0,0),False)
|
||||
temp_node.h_cost = math.inf
|
||||
temp_node.heap_index = len(self.items) - 1
|
||||
self.items.append(temp_node)
|
||||
item.heap_index = len(self.items) - 1
|
||||
# item.heap_index = len(self.items) - 1
|
||||
self.decrese_key(len(self.items) - 1, item)
|
||||
|
||||
def count(self):
|
||||
|
Loading…
Reference in New Issue
Block a user