"""Orbit Wars' built-in random agent, as kaggle-environments ships it.""" import math import random from collections import namedtuple Planet = namedtuple("Planet", ["id", "owner", "x", "y", "radius", "ships", "production"]) CENTER = 50.0 ROTATION_RADIUS_LIMIT = 50.0 def agent(obs, config=None): moves = [] player = obs.get("player", 0) planets = [Planet(*p) for p in obs.get("planets", [])] for p in planets: if p.owner == player and p.ships > 0: angle = random.uniform(0, 2 * math.pi) ships = p.ships // 2 if ships >= 20: moves.append([p.id, angle, ships]) return moves