Skip to content

Commit

Permalink
Modified heuristic function
Browse files Browse the repository at this point in the history
  • Loading branch information
Andeshog committed Mar 3, 2024
1 parent 02da37c commit 11d3d0b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion path_planner/D_star_lite/D_star_lite/dsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,11 @@ def c(self, node1: Node, node2: Node):

def h(self, s: Node):
# Can be modified
return 1
#return 1
#return max(abs(self.start.x - s.x), abs(self.start.y - s.y)) # Manhattan distance
dx = abs(self.start.x - s.x)
dy = abs(self.start.y - s.y)
return max(dx, dy) + (math.sqrt(2) - 1) * min(dx, dy) # Chebyshev distance

def calculate_key(self, s: Node):
return (min(self.g[s.x][s.y], self.rhs[s.x][s.y]) + self.h(s) + self.km, min(self.g[s.x][s.y], self.rhs[s.x][s.y]))
Expand Down

0 comments on commit 11d3d0b

Please sign in to comment.