Skip to content

Instantly share code, notes, and snippets.

View avivlevy37's full-sized avatar

Aviv Levy avivlevy37

View GitHub Profile
def do_turn(pw):
if len(pw.my_fleets()) >= 1:
return
source = -1
source_score = -999999.0
source_num_ships = 0
my_planets = pw.my_planets()
for p in my_planets:
score = float(p.num_ships())
if score > source_score:
@avivlevy37
avivlevy37 / MyBot.py
Created July 27, 2022 13:54
Team 1 PlanetWars Bot
NEUTRAL, MINE, ENEMY = 0, 1, 2
def try_attack(pw, dst):
dst_ships = dst.num_ships()
for planet in sorted(pw.my_planets(), key=lambda p: p.num_ships())[::-1]:
growth_rate_fix = pw.distance(planet, dst) * dst.growth_rate()
pw.debug(f"Distance: {pw.distance(planet, dst)}")
if planet.num_ships() <= growth_rate_fix:
continue
ships_to_send = planet.num_ships() / 2