|
|
@@ -64,14 +64,30 @@ func (ls *LinkerStrategy) attack(stars []*models.Star, flights []models.Flight, |
|
|
|
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) |
|
|
|
shipClause := (s.Ships / 2) |
|
|
|
if s.Ships > 20 { |
|
|
|
shipClause = s.Ships - 10 |
|
|
|
} |
|
|
|
|
|
|
|
enemyShipCountWithinFlight := t.Ships |
|
|
|
turns := flightTurnDistance |
|
|
|
|
|
|
|
if t.Turns < turns { |
|
|
|
turns -= t.Turns |
|
|
|
enemyShipCountWithinFlight += t.Richness |
|
|
|
} |
|
|
|
|
|
|
|
for 5 < turns { |
|
|
|
enemyShipCountWithinFlight += t.Richness |
|
|
|
turns -= 5 |
|
|
|
} |
|
|
|
|
|
|
|
insufficientShips := shipClause <= (enemyShipCountWithinFlight + 10) |
|
|
|
if t.Enemy() && insufficientShips { |
|
|
|
continue |
|
|
|
} |
|
|
|
|
|
|
|
shipCount := s.Ships / 2 |
|
|
|
shipCount := shipClause |
|
|
|
if shipCount < 6 { |
|
|
|
shipCount = 6 |
|
|
|
} |
|
|
@@ -101,14 +117,14 @@ func (ls *LinkerStrategy) linkFriendlies(stars []*models.Star, flights []models. |
|
|
|
|
|
|
|
// Keep a map of all the distances |
|
|
|
for i := 0; i < len(friendly); i++ { |
|
|
|
src := stars[i] |
|
|
|
src := stars[friendly[i]] |
|
|
|
|
|
|
|
if src.FlightsAllowed <= 0 { |
|
|
|
continue |
|
|
|
} |
|
|
|
|
|
|
|
for j := i + 1; j < len(friendly); j++ { |
|
|
|
dst, distance := stars[j], 0 |
|
|
|
dst, distance := stars[friendly[j]], 0 |
|
|
|
if src.Idx == dst.Idx { |
|
|
|
// Shouldn't happen, but oh well |
|
|
|
continue |