Advertisement
Guest User

Untitled

a guest
Aug 17th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. import math
  2.  
  3. def do_turn(pw):
  4. if len(pw.my_planets()) == 0:
  5. return
  6.  
  7. src = pw.my_planets()[0]
  8. dst = pw.my_planets()[0]
  9.  
  10. strongest_planet_id = 0
  11. strongest_planet_ships = 0
  12. strongest_x = 0
  13. strongest_y = 0
  14.  
  15. for planet in pw.my_planets():
  16. pw.debug(planet.planet_id())
  17. if (planet.num_ships() > strongest_planet_ships):
  18. strongest_planet_ships = planet.num_ships()
  19. strongest_planet_id = planet.planet_id()
  20. pw.debug("strongest=")
  21. pw.debug(strongest_planet_id)
  22. strongest_x = planet.x()
  23. strongest_y = planet.y()
  24.  
  25. weakest_planet_id = 0
  26. weakest_planet_ships = 99999
  27. dist = 999999
  28. smallest_dist = 99999
  29. if len(pw.neutral_planets()) != 0:
  30. for planet in pw.neutral_planets():
  31. dist = pw.distance(pw.get_planet(strongest_planet_id) , planet)
  32. if (dist < smallest_dist):
  33. weakest_planet_id = planet.planet_id()
  34. smallest_dist = dist
  35. # else if(planet.num_ships() < weakest_planet_ships):
  36. # weakest_planet_ships = planet.num_ships()
  37. # weakest_planet_id = planet.planet_id()
  38.  
  39. else:
  40. for planet in pw.not_my_planets():
  41. if(planet.num_ships() < weakest_planet_ships):
  42. weakest_planet_ships = planet.num_ships()
  43. weakest_planet_id = planet.planet_id()
  44. src = pw.get_planet(strongest_planet_id)
  45. dst = pw.get_planet(weakest_planet_id)
  46. pw.issue_order(src, dst, src.num_ships()/4)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement