Use cell hueristic for tentative g
This commit is contained in:
parent
a9fba17943
commit
182214c6d0
|
@ -64,7 +64,7 @@ func FindPath(w *World, fromX, fromY int, toX, toY int) ([]Node, bool) {
|
|||
|
||||
// Iterate over neighbors.
|
||||
for _, neighbor := range neighbors {
|
||||
tentativeG := current.g + 1
|
||||
tentativeG := current.g + 1 + int(w.At(int(neighbor.X), int(neighbor.Y)).Hueristic)
|
||||
distance := int(math.Abs(float64(neighbor.X)-float64(toX)) + math.Abs(float64(neighbor.Y)-float64(toY)))
|
||||
tentativeF := tentativeG + distance
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user