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]