From c638a3e72c7695c97f2bf3db4851a0b899a65dae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kinga=20Jagodzi=C5=84ska?= Date: Tue, 28 Apr 2020 23:34:27 +0000 Subject: [PATCH] Zaktualizuj 'Traktorek/Tractor.py' --- Traktorek/Tractor.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) 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):