Browse Source

Ensure we attack with at least 6 ships

master
Khaled Nassar 4 years ago
parent
commit
78ba6bcb1e
1 changed files with 8 additions and 3 deletions
  1. +8
    -3
      strategies/simple.go

+ 8
- 3
strategies/simple.go View File

@@ -31,7 +31,7 @@ func (s *SimpleStrategy) Execute(stars []*models.Star, flights []models.Flight,
// Determine target for this source
for j, t := range stars {
// Only target non-owned or enemy stars
if t.Owner != -1 && t.Owner != 2 {
if t.Friendly() || t.OwnedByMe() {
continue
}

@@ -45,13 +45,18 @@ func (s *SimpleStrategy) Execute(stars []*models.Star, flights []models.Flight,
// 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.Owner == 2 && insufficientShips {
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, s.Ships/2)
fmt.Printf("fly %d %d %d\n", i, j, shipCount)
s.FlightsAllowed--
break
}

Loading…
Cancel
Save