diff --git a/Traktorek/Tractor.py b/Traktorek/Tractor.py index 8bd3b15..962a667 100644 --- a/Traktorek/Tractor.py +++ b/Traktorek/Tractor.py @@ -16,8 +16,7 @@ class Tractor(object): # A* self.g_score = [] - self.f_score = [] - self.h_score = [] + self.f_score = [ self.came_from = [] self.neighbours() self.score() @@ -75,13 +74,12 @@ class Tractor(object): for x in range(25): self.g_score.append(0) self.f_score.append(0) - self.h_score.append(0) self.came_from.append(0) # Obliczanie h (założenie - odległość pomiędzy sąsiednimi polami wynosi 2, tak jak koszt wjazdu na puste pole) # s to pole na którym jesteśmy # f to pole końcowe - def hscore(self, s, f): + def h_score(self, s, f): a_h = m.fabs(s - f) // 5 b_h = m.fabs(f % 5 - s % 5) return 2 * m.sqrt(a_h ** 2 + b_h ** 2) @@ -118,7 +116,7 @@ class Tractor(object): if tentative_is_better == True: self.came_from[y] = x self.g_score[y] = tentative_g_score - self.f_score[y] = self.g_score[y] + self.hscore(y, koniec) + self.f_score[y] = self.g_score[y] + self._score(y, koniec) print("failure") def reconstruct_path(self, came_from, current):