Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- def do_turn(pw):
- if len(pw.my_planets()) == 0:
- return
- src = pw.my_planets()[0]
- dst = pw.my_planets()[0]
- strongest_planet_id = 0
- strongest_planet_ships = 0
- strongest_x = 0
- strongest_y = 0
- for planet in pw.my_planets():
- pw.debug(planet.planet_id())
- if (planet.num_ships() > strongest_planet_ships):
- strongest_planet_ships = planet.num_ships()
- strongest_planet_id = planet.planet_id()
- pw.debug("strongest=")
- pw.debug(strongest_planet_id)
- strongest_x = planet.x()
- strongest_y = planet.y()
- weakest_planet_id = 0
- weakest_planet_ships = 99999
- dist = 999999
- smallest_dist = 99999
- if len(pw.neutral_planets()) != 0:
- for planet in pw.neutral_planets():
- dist = pw.distance(pw.get_planet(strongest_planet_id) , planet)
- if (dist < smallest_dist):
- weakest_planet_id = planet.planet_id()
- smallest_dist = dist
- # else if(planet.num_ships() < weakest_planet_ships):
- # weakest_planet_ships = planet.num_ships()
- # weakest_planet_id = planet.planet_id()
- else:
- for planet in pw.not_my_planets():
- if(planet.num_ships() < weakest_planet_ships):
- weakest_planet_ships = planet.num_ships()
- weakest_planet_id = planet.planet_id()
- src = pw.get_planet(strongest_planet_id)
- dst = pw.get_planet(weakest_planet_id)
- pw.issue_order(src, dst, src.num_ships()/4)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement