Heuristic for the A*
(self)
| 61 | self.f_cost = self.g_cost + self.h_cost |
| 62 | |
| 63 | def calculate_heuristic(self) -> float: |
| 64 | """ |
| 65 | Heuristic for the A* |
| 66 | """ |
| 67 | dy = self.pos_x - self.goal_x |
| 68 | dx = self.pos_y - self.goal_y |
| 69 | if HEURISTIC == 1: |
| 70 | return abs(dx) + abs(dy) |
| 71 | else: |
| 72 | return sqrt(dy**2 + dx**2) |
| 73 | |
| 74 | def __lt__(self, other: Node) -> bool: |
| 75 | return self.f_cost < other.f_cost |