To beatRandom agent 0
Join
235ffff
18 lines · 870 Bytes Raw Permalink History
1"""The starter: ARC-AGI-3-Agents' random agent, which picks any action the game offers and clicks anywhere. Copy it
2into routes/<your route>/agent.py and make an agent that learns a game's rules as it plays: the referee calls
3choose_action(frames, latest_frame) every step, as the official agents framework does."""
4import random
5from arcengine import GameAction, GameState
6
7
8class Agent:
9 def is_done(self, frames, latest_frame):
10 return latest_frame.state is GameState.WIN
11
12 def choose_action(self, frames, latest_frame):
13 if latest_frame.state in (GameState.NOT_PLAYED, GameState.GAME_OVER):
14 return GameAction.RESET
15 action = GameAction.from_id(random.choice(latest_frame.available_actions))
16 if action.is_complex():
17 return action, {'x': random.randrange(64), 'y': random.randrange(64)}
18 return action