Skip to content

Commit 33cd041

Browse files
committed
Fixes #44; Add handling for when 1+ submissions are broken
1 parent f6b1d7b commit 33cd041

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

codeclash/games/game.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from minisweagent.environments.docker import DockerEnvironment
1010

1111
from codeclash.agents.player import Player
12-
from codeclash.constants import DIR_LOGS, DIR_WORK, GH_ORG
12+
from codeclash.constants import DIR_LOGS, DIR_WORK, GH_ORG, RESULT_TIE
1313
from codeclash.utils.environment import assert_zero_exit_code, copy_between_containers, copy_from_container
1414
from codeclash.utils.log import get_logger
1515

@@ -208,7 +208,7 @@ def run_round(self, agents: list[Player], round_num: int) -> RoundStats:
208208
"""
209209
random.shuffle(agents) # Shuffle to ensure fairness in case of positional advantages
210210
stats = RoundStats(round_num, agents)
211-
validated = []
211+
validated: list[Player] = []
212212
for agent in agents:
213213
is_valid, error = self.validate_code(agent)
214214
if not is_valid:
@@ -219,12 +219,17 @@ def run_round(self, agents: list[Player], round_num: int) -> RoundStats:
219219
stats.player_stats[agent.name].valid_submit = True
220220
validated.append(agent)
221221

222-
run_game = len(validated) > 1
223-
if run_game:
222+
if len(validated) > 1:
224223
self._pre_round_setup(validated)
225224
self.execute_round(validated)
226225
self.copy_logs_from_env(round_num)
227226
self.get_results(validated, round_num, stats)
227+
elif len(validated) == 1:
228+
self.logger.info(f"Only one valid agent ({validated[0].name}), automatic win")
229+
stats.winner = validated[0].name
230+
else:
231+
self.logger.info("No valid agents, no winner this round (Default tie)")
232+
stats.winner = RESULT_TIE
228233
return stats
229234

230235
@abstractmethod

0 commit comments

Comments
 (0)