drobna poprawa A*

This commit is contained in:
Łukasz Kinder 2022-04-28 21:34:54 +02:00
parent 421b42d578
commit efa0e7ddfc

View File

@ -308,7 +308,7 @@ def astar(map, start, end):
current_tile = open_list[0]
current_index = 0
for index, item in enumerate(open_list):
if item.f < current_tile.f:
if item.f <= current_tile.f:
current_tile = item
current_index = index
@ -336,7 +336,7 @@ def astar(map, start, end):
if child == closed_child:
skip = True
if skip is False:
child.g = map[child.position[0]][child.position[1]]
child.g = current_tile.g + map[child.position[0]][child.position[1]]
child.h = np.absolute(child.position[0] - end_tile.position[0]) + np.absolute(child.position[1] - end_tile.position[1])
child.f = child.g + child.h
for open_node in open_list:
@ -344,6 +344,7 @@ def astar(map, start, end):
continue
open_list.append(child)
map = Map()
waiter = Waiter([32, 32])
tables = []