Advertisement
Guest User

Untitled

a guest
Aug 17th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. NETURAL = 0
  2. ALLY = 1
  3. ENEMY = 2
  4.  
  5. def do_turn(pw):
  6. if not pw.my_planets():
  7. return
  8. if not pw.not_my_planets():
  9. return
  10.  
  11. for planet in pw.my_planets():
  12. for enemy in get_closest_pl(pw, planet)[:3]:
  13. if planet.num_ships() > 14:
  14. pw.issue_order(planet, enemy, planet.num_ships() * 0.5)
  15. planet.remove_ships(planet.num_ships() * 0.5)
  16.  
  17.  
  18. #print('pppppp:', pw.enemy_planets()[0].planet_id)
  19.  
  20.  
  21. #def defend(pw):
  22. # for fleet in pw.enemy_fleets():
  23. # if fleet.owner() == ENEMY and fleet.destination_planet().owner() == ALLY:
  24.  
  25.  
  26.  
  27. def ships_in_attack(pw, a, p):
  28. res = p.num_ships()
  29. if p.owner() == ENEMY:
  30. res += pw.distance(a, p) * p.growth_rate()
  31. return res
  32.  
  33. def get_closest_pl(pw,pl):
  34. planets = sorted(pw.not_my_planets(), key=lambda x:(x.growth_rate() / (x.num_ships() * 0.128 + pw.distance(x, pl) * 1.11)), reverse=True)
  35. return planets
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement