# robosoccer-kit: 0.3.0 """Starter: run with robosoccer run my_bot.py --vs chaser --seed 3.""" import math def setup(info: dict) -> dict | None: """Called once per team; initial state is copied into each robot's memory slot.""" return {"speed": info["robot"]["cruise_speed"], "last_bearing": 0.0} def act(robot_id: int, sensors: dict, memory: dict) -> dict: """Called independently per robot. Use broadcast for team coordination.""" balls = [obj for obj in sensors["camera"] if obj["kind"] == "ball"] if balls: ball = min(balls, key=lambda obj: obj["distance"]) memory["last_bearing"] = ball["bearing"] return {"move": (memory["speed"] * max(0, math.cos(ball["bearing"])), 4 * ball["bearing"]), "kick": 1.0 if sensors["ball_in_kicker"] else 0.0, "broadcast": [robot_id, ball["bearing"], ball["distance"]]} turn = 1.4 if memory["last_bearing"] >= 0 else -1.4 return {"move": (0.0, turn), "kick": 0.0}