|
- package strategies
-
- import (
- "botg/models"
- "fmt"
- )
-
- type SimpleStrategy struct {
- }
-
- func (s *SimpleStrategy) Execute(stars []*models.Star, flights []models.Flight, links []models.Link) {
-
- for i, s := range stars {
- // No more flights allowed for that node
- if s.FlightsAllowed <= 0 {
- continue
- }
-
- // Only process owned stars
- if s.Owner != 0 || s.Ships == 0 {
- continue
- }
-
- // Wait till we have a sufficient number of ships
- if s.Ships < 10 {
- continue
- }
-
- //fmt.Printf("Links: %d\n", len(links))
- //fmt.Printf("SOURCE => IDX=%d, X=%d, Y=%d, OWNER=%d, RICH=%d, SHIPS=%d\n", s.Idx, s.X, s.Y, s.Owner, s.Richness, s.Ships)
- // Determine target for this source
- for j, t := range stars {
- // Only target non-owned or enemy stars
- if t.Friendly() || t.OwnedByMe() {
- continue
- }
-
- // Check if ship is within distance
- //fmt.Printf("TARGET => IDX=%d, X=%d, Y=%d, OWNER=%d, RICH=%d, SHIPS=%d\n", t.Idx, t.X, t.Y, t.Owner, t.Richness, t.Ships)
- flightTurnDistance := flightTurnDistance(s, t)
- if flightTurnDistance > 6 {
- continue
- }
-
- // If enemy star, make sure we have enough ships to attack it
- //if t.Owner == 2 && (s.Ships - (t.Ships + (flightTurnDistance * t.Richness))) <= 1 {
- insufficientShips := (s.Ships / 2) <= ((t.Ships + (flightTurnDistance * t.Richness)) + 5)
- if t.Enemy() && insufficientShips {
- continue
- }
-
- shipCount := s.Ships / 2
- if shipCount < 6 {
- shipCount = 6
- }
-
- // TODO: Find best destination
- // Fly to this target, and skip processing all remaining potential target stars
- fmt.Printf("fly %d %d %d\n", i, j, shipCount)
- s.FlightsAllowed--
- break
- }
- }
-
- }
|