| 1 | """Orbit Wars' built-in random agent, as kaggle-environments ships it.""" |
| 2 | import math |
| 3 | import random |
| 4 | from collections import namedtuple |
| 5 | |
| 6 | Planet = namedtuple("Planet", ["id", "owner", "x", "y", "radius", "ships", "production"]) |
| 7 | CENTER = 50.0 |
| 8 | ROTATION_RADIUS_LIMIT = 50.0 |
| 9 | |
| 10 | def agent(obs, config=None): |
| 11 | moves = [] |
| 12 | player = obs.get("player", 0) |
| 13 | planets = [Planet(*p) for p in obs.get("planets", [])] |
| 14 | for p in planets: |
| 15 | if p.owner == player and p.ships > 0: |
| 16 | angle = random.uniform(0, 2 * math.pi) |
| 17 | ships = p.ships // 2 |
| 18 | if ships >= 20: |
| 19 | moves.append([p.id, angle, ships]) |
| 20 | return moves |
