MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / calculate_heuristic

Method calculate_heuristic

graphs/bidirectional_a_star.py:63–72  ·  view source on GitHub ↗

Heuristic for the A*

(self)

Source from the content-addressed store, hash-verified

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

Callers 1

__init__Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected