|
17 | 17 | from codeclash.tournaments.tournament import AbstractTournament |
18 | 18 | from codeclash.utils.atomic_write import atomic_write |
19 | 19 | from codeclash.utils.aws import is_running_in_aws_batch, s3_log_sync |
20 | | -from codeclash.utils.environment import copy_to_container |
| 20 | +from codeclash.utils.environment import copy_between_containers, copy_to_container |
21 | 21 |
|
22 | 22 |
|
23 | 23 | class PvpTournament(AbstractTournament): |
@@ -53,6 +53,10 @@ def metadata_file(self) -> Path: |
53 | 53 | def rounds(self) -> int: |
54 | 54 | return self.config["tournament"]["rounds"] |
55 | 55 |
|
| 56 | + @property |
| 57 | + def transparent(self) -> bool: |
| 58 | + return self.config["tournament"].get("transparent", False) |
| 59 | + |
56 | 60 | def get_metadata(self) -> dict: |
57 | 61 | # will be saved in end() |
58 | 62 | return { |
@@ -120,6 +124,21 @@ def run_edit_phase(self, round_num: int) -> None: |
120 | 124 | ) |
121 | 125 | self._compress_round_folder(round_num - 1) |
122 | 126 |
|
| 127 | + if self.transparent: |
| 128 | + # Copy agent's codebase to all other agents |
| 129 | + self.logger.info("Transparent mode enabled: copying codebases between agents...") |
| 130 | + for idx in range(len(self.agents)): |
| 131 | + agent = self.agents[idx] |
| 132 | + opponents = [a for j, a in enumerate(self.agents) if j != idx] |
| 133 | + self.logger.info(f"Copying {agent.name}'s codebase to other agents...") |
| 134 | + for opp in opponents: |
| 135 | + copy_between_containers( |
| 136 | + agent.environment, |
| 137 | + opp.environment, |
| 138 | + agent.environment.config.cwd, |
| 139 | + f"/{agent.name}/", |
| 140 | + ) |
| 141 | + |
123 | 142 | with ThreadPoolExecutor() as executor: |
124 | 143 | futures = [executor.submit(self.run_agent, agent, round_num) for agent in self.agents] |
125 | 144 | for future in futures: |
|
0 commit comments