| 22 | |
| 23 | |
| 24 | class PvpTournament(AbstractTournament): |
| 25 | def __init__( |
| 26 | self, |
| 27 | config: dict, |
| 28 | *, |
| 29 | output_dir: Path, |
| 30 | cleanup: bool = False, |
| 31 | keep_containers: bool = False, |
| 32 | early_stop: Callable[[list[str]], bool] | None = None, |
| 33 | ): |
| 34 | metadata_file = output_dir / "metadata.json" |
| 35 | if metadata_file.exists(): |
| 36 | raise FileExistsError(f"Metadata file already exists: {metadata_file}") |
| 37 | |
| 38 | super().__init__(config, name="PvpTournament", output_dir=output_dir) |
| 39 | self.cleanup_on_end = cleanup |
| 40 | # Given the agent-round winners so far (rounds 1..n), return True to stop before `rounds`. |
| 41 | self.early_stop = early_stop |
| 42 | self.game: CodeArena = get_arena( |
| 43 | self.config, |
| 44 | tournament_id=self.tournament_id, |
| 45 | local_output_dir=self.local_output_dir, |
| 46 | keep_containers=keep_containers, |
| 47 | ) |
| 48 | self.agents: list[Player] = [] |
| 49 | for agent_conf in self.config["players"]: |