The heuristic here is the Manhattan Distance Could elaborate to offer more than one choice
(self)
| 72 | self.f_cost = self.calculate_heuristic() |
| 73 | |
| 74 | def calculate_heuristic(self) -> float: |
| 75 | """ |
| 76 | The heuristic here is the Manhattan Distance |
| 77 | Could elaborate to offer more than one choice |
| 78 | """ |
| 79 | dx = abs(self.pos_x - self.goal_x) |
| 80 | dy = abs(self.pos_y - self.goal_y) |
| 81 | return dx + dy |
| 82 | |
| 83 | def __lt__(self, other) -> bool: |
| 84 | return self.f_cost < other.f_cost |