Run a single round of the game with the given agents. Returns the log output, result output, and winner name. All bookkeeping should be handled by the tournament class.
(self, agents: list[Player], round_num: int, *, copy_logs: bool = True)
| 250 | src_path=DIR_WORK, |
| 251 | dest_path=f"/{agent.name}", |
| 252 | ) |
| 253 | |
| 254 | assert_zero_exit_code( |
| 255 | self.environment.execute(f"mkdir -p {self.log_env}"), |
| 256 | logger=self.logger, |
| 257 | ) |
| 258 | |
| 259 | def run_round(self, agents: list[Player], round_num: int, *, copy_logs: bool = True) -> RoundStats: |
| 260 | """ |
| 261 | Run a single round of the game with the given agents. |
| 262 | |
| 263 | Returns the log output, result output, and winner name. All bookkeeping should be |
| 264 | handled by the tournament class. |
| 265 | """ |
| 266 | all_names = {agent.name for agent in agents} |
| 267 | assert len(all_names) == len(agents), "All agents must have unique names" |
| 268 | |
| 269 | random.shuffle(agents) # Shuffle to ensure fairness in case of positional advantages |
| 270 | stats = RoundStats(round_num, agents) |
| 271 | validated: list[Player] = [] |
| 272 | for a in agents: |
| 273 | is_valid, error = self.validate_code(a) |
| 274 | if not is_valid: |
| 275 | self.logger.warning(f"Agent {a.name} failed submission validation: {error}") |
| 276 | stats.player_stats[a.name].invalid_reason = error |
| 277 | continue |
| 278 | self.logger.info(f"Agent {a.name} passed submission validation") |
| 279 | stats.player_stats[a.name].valid_submit = True |
| 280 | validated.append(a) |
| 281 | |
| 282 | sims = self.config["game"]["sims_per_round"] |
| 283 | if len(validated) > 1: |
| 284 | self._pre_round_setup(validated) |
| 285 | self.execute_round(validated) |
| 286 | if copy_logs: |
| 287 | self.copy_logs_from_env(round_num) |
| 288 | self.get_results(validated, round_num, stats) |
| 289 | elif len(validated) == 1: |
| 290 | self.logger.info(f"Only one valid agent ({validated[0].name}), automatic win") |
| 291 | stats.winner = validated[0].name |
| 292 | stats.scores[validated[0].name] = sims |
| 293 | stats.player_stats[validated[0].name].score = sims |
| 294 | else: |
| 295 | self.logger.info("No valid agents, no winner this round (Default tie)") |
| 296 | stats.winner = RESULT_TIE |
| 297 | # Split points evenly |
| 298 | points = sims * 1.0 / len(agents) |
no test coverage detected