"""A bot's own process, in Kaggle's own interface: main.py defines agent(obs, config) (or, as Kaggle allows, its last function is the agent) and returns the game's action. The observation and configuration arrive as JSON and are handed over as kaggle_environments Structs, so obs.planets and obs["planets"] both work, as on Kaggle. python3 -I referee/kaggle_child.py """ import os, sys sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'kit')) import inspect, random # noqa: E402 from host import load, serve # noqa: E402 from kaggle_environments.utils import structify # noqa: E402 random.seed(0) # a bot's own randomness is seeded, so a check gives the same score every time agent = load(sys.argv[1], 'agent') takes = len(inspect.signature(agent).parameters) def handle(msg): obs, config = structify(msg['obs']), structify(msg['config']) return agent(obs, config) if takes > 1 else agent(obs) serve(handle)