|
|
@@ -3,13 +3,14 @@ package strategies |
|
|
|
import ( |
|
|
|
"botg/models" |
|
|
|
"fmt" |
|
|
|
"math" |
|
|
|
) |
|
|
|
|
|
|
|
type SimpleStrategy struct { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
func (s SimpleStrategy) Execute(stars[] models.Star, flights[] models.Flight, links[] models.Link) { |
|
|
|
func (s *SimpleStrategy) Execute(stars[] models.Star, flights[] models.Flight, links[] models.Link) { |
|
|
|
total := 0 |
|
|
|
|
|
|
|
for i, s := range stars { |
|
|
@@ -48,7 +49,7 @@ func (s SimpleStrategy) Execute(stars[] models.Star, flights[] models.Flight, li |
|
|
|
|
|
|
|
// Fly to this target, and skip processing all remaining potential target stars |
|
|
|
fmt.Printf("fly %d %d %d\n", i, j, s.Ships / 2) |
|
|
|
total += 1 |
|
|
|
total++ |
|
|
|
break |
|
|
|
} |
|
|
|
|
|
|
@@ -60,3 +61,22 @@ func (s SimpleStrategy) Execute(stars[] models.Star, flights[] models.Flight, li |
|
|
|
|
|
|
|
fmt.Println("done") |
|
|
|
} |
|
|
|
|
|
|
|
func flightTurnDistance(x, y int, star *models.Star) int { |
|
|
|
pointDistance := distanceBetweenPoints(x, y, star.X, star.Y) |
|
|
|
|
|
|
|
if pointDistance == 0 { |
|
|
|
return 0 |
|
|
|
} |
|
|
|
|
|
|
|
return int(math.Ceil(pointDistance / 10)) |
|
|
|
} |
|
|
|
|
|
|
|
func distanceBetweenPoints(x1, y1, x2, y2 int) float64 { |
|
|
|
// Is it the same point? The distance is defined as 0 |
|
|
|
if x1 == x2 && y1 == y2 { |
|
|
|
return 0 |
|
|
|
} |
|
|
|
|
|
|
|
return math.Sqrt(math.Pow(float64(x1 - x2), 2) + math.Pow(float64(y1 - y2), 2)) |
|
|
|
} |