From c96e45bd0868d14734cd9322a2b714928ecc4fe0 Mon Sep 17 00:00:00 2001 From: s444349 Date: Sun, 26 Apr 2020 13:56:26 +0200 Subject: [PATCH] poprawa astara --- astar.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/astar.py b/astar.py index 96258d7..63245ea 100644 --- a/astar.py +++ b/astar.py @@ -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]