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 {
|
a.heuristic = func(x int, y int, endX int, endY int) float32 {
|
||||||
return float32(math.Max(float64(x-endX), float64(y-endY))) // Chebyshev distance
|
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -299,7 +299,7 @@ func main() {
|
|||||||
toolDropdownOpen := false
|
toolDropdownOpen := false
|
||||||
var tex texSync // GPU uploads: partial rects while painting; full after path resets
|
var tex texSync // GPU uploads: partial rects while painting; full after path resets
|
||||||
|
|
||||||
heuristicOptions := []string{"Manhattan", "Euclidean", "Chebyshev"}
|
heuristicOptions := []string{"Manhattan", "Euclidean", "Chebyshev", "Squared Euclidean"}
|
||||||
heuristicOptionsText := strings.Join(heuristicOptions, ";")
|
heuristicOptionsText := strings.Join(heuristicOptions, ";")
|
||||||
activeHeuristic := int32(0)
|
activeHeuristic := int32(0)
|
||||||
heuristicDropdownOpen := false
|
heuristicDropdownOpen := false
|
||||||
|
|||||||
Reference in New Issue
Block a user