mirror of
https://github.com/wisplite/a-star-go.git
synced 2026-06-27 15:37:07 -05:00
added square euclidean at the dismay of many theoretical mathematicians (it's inadmissible) (but it's really fast)
This commit is contained in:
@@ -109,6 +109,10 @@ func (a *AStar) SetHeuristic(heuristic int32) {
|
||||
a.heuristic = func(x int, y int, endX int, endY int) float32 {
|
||||
return float32(math.Max(float64(x-endX), float64(y-endY))) // Chebyshev distance
|
||||
}
|
||||
case 3:
|
||||
a.heuristic = func(x int, y int, endX int, endY int) float32 {
|
||||
return float32(math.Pow(float64(x-endX), 2) + math.Pow(float64(y-endY), 2)) // Squared Euclidean (extremely fast but not optimal/inadmissible)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user