Skip to content

Commit f08528c

Browse files
committed
Add score handling for invalid submissions
1 parent de1f72c commit f08528c

2 files changed

Lines changed: 22 additions & 14 deletions

File tree

codeclash/games/game.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def __init__(self, round_num: int, agents: list[Player]):
3636
self.winner = None
3737
self.round_num = round_num
3838
# Map of player to game metric (e.g. # of wins, assets accumulated)
39-
self.scores: dict[str, float] = {}
39+
self.scores: dict[str, float] = {a.name: 0.0 for a in agents}
4040
self.player_stats: dict[str, PlayerStats] = {agent.name: PlayerStats(name=agent.name) for agent in agents}
4141
self.details: list[str] = []
4242

@@ -254,16 +254,17 @@ def run_round(self, agents: list[Player], round_num: int, *, copy_logs: bool = T
254254
random.shuffle(agents) # Shuffle to ensure fairness in case of positional advantages
255255
stats = RoundStats(round_num, agents)
256256
validated: list[Player] = []
257-
for agent in agents:
258-
is_valid, error = self.validate_code(agent)
257+
for a in agents:
258+
is_valid, error = self.validate_code(a)
259259
if not is_valid:
260-
self.logger.warning(f"Agent {agent.name} failed submission validation: {error}")
261-
stats.player_stats[agent.name].invalid_reason = error
260+
self.logger.warning(f"Agent {a.name} failed submission validation: {error}")
261+
stats.player_stats[a.name].invalid_reason = error
262262
continue
263-
self.logger.info(f"Agent {agent.name} passed submission validation")
264-
stats.player_stats[agent.name].valid_submit = True
265-
validated.append(agent)
263+
self.logger.info(f"Agent {a.name} passed submission validation")
264+
stats.player_stats[a.name].valid_submit = True
265+
validated.append(a)
266266

267+
sims = self.config["game"]["sims_per_round"]
267268
if len(validated) > 1:
268269
self._pre_round_setup(validated)
269270
self.execute_round(validated)
@@ -273,9 +274,16 @@ def run_round(self, agents: list[Player], round_num: int, *, copy_logs: bool = T
273274
elif len(validated) == 1:
274275
self.logger.info(f"Only one valid agent ({validated[0].name}), automatic win")
275276
stats.winner = validated[0].name
277+
stats.scores[validated[0].name] = sims
278+
stats.player_stats[validated[0].name].score = sims
276279
else:
277280
self.logger.info("No valid agents, no winner this round (Default tie)")
278281
stats.winner = RESULT_TIE
282+
# Split points evenly
283+
points = sims * 1.0 / len(agents)
284+
for a in agents:
285+
stats.scores[a.name] = points
286+
stats.player_stats[a.name].score = points
279287
return stats
280288

281289
@abstractmethod

configs/scripts/main_tracker.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,23 +60,23 @@
6060
"glm-4-5.grok-code-fast-1": "0 (0 rounds)",
6161
"gpt-5.grok-code-fast-1": "11 (167 rounds)",
6262
"gpt-5-mini.grok-code-fast-1": "10 (160 rounds)",
63-
"grok-code-fast-1.qwen3-coder-plus-2025-09-23": "1 (4 rounds)",
63+
"grok-code-fast-1.qwen3-coder-plus-2025-09-23": "10 (120 rounds)",
6464
"grok-code-fast-1.o3": "10 (158 rounds)",
6565
"gemini-2.5-pro.glm-4-5": "0 (0 rounds)",
66-
"gemini-2.5-pro.gpt-5": "6 (72 rounds)",
66+
"gemini-2.5-pro.gpt-5": "10 (147 rounds)",
6767
"gemini-2.5-pro.gpt-5-mini": "10 (160 rounds)",
68-
"gemini-2.5-pro.qwen3-coder-plus-2025-09-23": "1 (5 rounds)",
68+
"gemini-2.5-pro.qwen3-coder-plus-2025-09-23": "10 (134 rounds)",
6969
"gemini-2.5-pro.o3": "10 (160 rounds)",
7070
"glm-4-5.gpt-5": "0 (0 rounds)",
7171
"glm-4-5.gpt-5-mini": "0 (0 rounds)",
7272
"glm-4-5.qwen3-coder-plus-2025-09-23": "0 (0 rounds)",
7373
"glm-4-5.o3": "0 (0 rounds)",
7474
"gpt-5.gpt-5-mini": "10 (155 rounds)",
75-
"gpt-5.qwen3-coder-plus-2025-09-23": "1 (2 rounds)",
75+
"gpt-5.qwen3-coder-plus-2025-09-23": "6 (80 rounds)",
7676
"gpt-5.o3": "10 (160 rounds)",
77-
"gpt-5-mini.qwen3-coder-plus-2025-09-23": "1 (4 rounds)",
77+
"gpt-5-mini.qwen3-coder-plus-2025-09-23": "10 (160 rounds)",
7878
"gpt-5-mini.o3": "10 (160 rounds)",
79-
"o3.qwen3-coder-plus-2025-09-23": "1 (5 rounds)"
79+
"o3.qwen3-coder-plus-2025-09-23": "10 (160 rounds)"
8080
}
8181
},
8282
"CoreWar": {

0 commit comments

Comments
 (0)