MCPcopy Create free account
hub / github.com/CodeClash-ai/CodeClash / DummyArena

Class DummyArena

codeclash/arenas/dummy/dummy.py:10–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8
9
10class DummyArena(CodeArena):
11 name: str = "Dummy"
12 description: str = """WARNING: This is a dummy game meant for testing the CodeClash infrastructure. It does not represent a real game."""
13 submission: str = "main.py"
14
15 def execute_round(self, agents: list[Player]) -> None:
16 args = [f"/{agent.name}/{self.submission}" for agent in agents]
17 cmd = f"python engine.py {' '.join(args)} -r {self.game_config['sims_per_round']} > {self.log_env / DUMMY_LOG};"
18 self.logger.info(f"Running game: {cmd}")
19 assert_zero_exit_code(self.environment.execute(cmd))
20
21 def get_results(self, agents: list[Player], round_num: int, stats: RoundStats):
22 with open(self.log_round(round_num) / DUMMY_LOG) as f:
23 round_log = f.read()
24 lines = round_log.split("FINAL_RESULTS")[-1].splitlines()
25
26 scores = {}
27 for line in lines:
28 match = re.search(r"Bot\_(\d)\_main:\s(\d+)\srounds\swon", line)
29 if match:
30 bot_id = match.group(1)
31 rounds_won = int(match.group(2))
32 scores[agents[int(bot_id) - 1].name] = rounds_won
33
34 stats.winner = max(scores, key=scores.get) if scores else "unknown"
35 stats.scores = scores
36 for player, score in scores.items():
37 stats.player_stats[player].score = score
38
39 def validate_code(self, agent: Player) -> tuple[bool, str | None]:
40 # TODO: implement more checks
41 return True, None

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected