|
- package strategies
-
- import (
- "botg/models"
- "math"
- )
-
- type StarAffiliation int
-
- const (
- Own StarAffiliation = 0
- Friend StarAffiliation = 1
- Enemy StarAffiliation = 2
- )
-
- func calculateDistanceCeiling(source *models.Star, target *models.Star) int {
- squareDist := (source.X - target.X) * (source.X - target.X) + int(source.Y - target.Y) * (source.Y - target.Y)
-
- lb := 1
- ub := 300 * 2
- for lb < ub {
- mb := (lb + ub) / 2
- if int(mb*mb) >= squareDist {
- ub = mb
- } else {
- lb = mb + 1
- }
- }
-
- return lb
- }
-
- func flightTurnDistance(source, target *models.Star) int {
- if source.Idx == target.Idx {
- return 0
- }
-
- return int(math.Ceil(float64(calculateDistanceCeiling(source, target)) / 10.0))
- }
|