Tune pathfinding and movements

This commit is contained in:
Tom
2020-09-23 23:52:28 -07:00
parent 39379d1388
commit 8384eb99de
2 changed files with 9 additions and 9 deletions

View File

@ -199,20 +199,20 @@ func (m Movement) BaseCost() float64 {
case Waypoint: case Waypoint:
return 0 return 0
case TraverseNorth, TraverseSouth, TraverseEast, TraverseWest: case TraverseNorth, TraverseSouth, TraverseEast, TraverseWest:
return 1 return 2
case TraverseNorthWest, TraverseNorthEast, TraverseSouthWest, TraverseSouthEast: case TraverseNorthWest, TraverseNorthEast, TraverseSouthWest, TraverseSouthEast:
return 1.25 return 2.5
case DropNorth, DropSouth, DropEast, DropWest: case DropNorth, DropSouth, DropEast, DropWest:
return 2 return 4
case AscendNorth, AscendSouth, AscendEast, AscendWest: case AscendNorth, AscendSouth, AscendEast, AscendWest:
return 2.25 return 4
case DescendLadderNorth, DescendLadderSouth, DescendLadderEast, DescendLadderWest: case DescendLadderNorth, DescendLadderSouth, DescendLadderEast, DescendLadderWest:
return 1.5 return 1.5
case DescendLadder: case DescendLadder:
return 1.2 return 1
case AscendLadder: case AscendLadder:
return 1.5 return 3
default: default:
panic(m) panic(m)
} }

View File

@ -19,7 +19,7 @@ type V3 struct {
func (v V3) Cost(other V3) float64 { func (v V3) Cost(other V3) float64 {
x, y, z := v.X-other.X, v.Y-other.Y, v.Z-other.Z x, y, z := v.X-other.X, v.Y-other.Y, v.Z-other.Z
return float64(x*x+z*z) + 1.2*float64(y*y) return math.Sqrt(float64(x*x+z*z)) + math.Sqrt(1.2*float64(y*y))
} }
// Nav represents a navigation to a position. // Nav represents a navigation to a position.
@ -119,8 +119,8 @@ func (t Tile) Inputs(pos, deltaPos, vel Point) Inputs {
pos.X -= (0.55 * float64(x)) pos.X -= (0.55 * float64(x))
pos.Z -= (0.55 * float64(z)) pos.Z -= (0.55 * float64(z))
} else { } else {
pos.X += (0.55 * float64(x)) pos.X += (0.42 * float64(x))
pos.Z += (0.55 * float64(z)) pos.Z += (0.42 * float64(z))
} }
at = math.Atan2(-pos.X+float64(t.Pos.X)+0.5, -pos.Z+float64(t.Pos.Z)+0.5) at = math.Atan2(-pos.X+float64(t.Pos.X)+0.5, -pos.Z+float64(t.Pos.Z)+0.5)