poprawa astara

This commit is contained in:
s444349 2020-04-26 13:56:26 +02:00
parent 7cb3aa904c
commit c96e45bd08

View File

@ -5,8 +5,6 @@ def heurystyka(obiekty, a, b):
heur = abs((b[0] - a[0])) + abs((b[1] - a[1]))
if obiekty["plansza"][b[0], b[1]].jestDomem is True:
heur += 2
if obiekty["plansza"][b[0], b[1]].jestPrzeszkoda is True:
heur += 100
return heur
@ -44,9 +42,9 @@ def astar(obiekty, start, cel):
continue
tentative_h_score = heurystyka(obiekty, sasiad, cel) + heurystyka(obiekty, current, sasiad)
if sasiad in [i[1] for i in oheap] and tentative_h_score > hscore.get(current, 0):
if sasiad in [i[1] for i in oheap] and tentative_h_score < hscore.get(current, 0):
continue
if sasiad not in close_set and sasiad not in [i[1] for i in oheap]:
elif sasiad not in close_set and sasiad not in [i[1] for i in oheap]:
came_from[sasiad] = current
hscore[sasiad] = tentative_h_score
fscore[sasiad] = tentative_h_score + gscore[current]