Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def do_turn(pw):
- if len(pw.my_fleets()) >= 1:
- return
- if len(pw.my_planets()) == 0:
- return
- else:
- my_planet_list = pw.my_planets()
- my_planet_list.sort(key=myFunc, reverse=True)
- for i in range(0, len(my_planet_list)):
- dest = get_closest_neutral_planet(pw, my_planet_list[i])
- if my_planet_list[i].num_ships() > dest.num_ships():
- pw.issue_order(my_planet_list[i], dest, dest.num_ships() + 1)
- def myFunc(planet):
- return planet.num_ships()
- def get_closest_neutral_planet(pw, source):
- try:
- min_dist = 1000
- dest = pw.not_my_planets()[0]
- cost = 0
- for p in pw.not_my_planets():
- if min_dist > pw.distance(source, p):
- min_dist = pw.distance(source, p)
- dest = p
- except:
- dest = 0
- return dest
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement