|
8 | 8 | from codeclash.arenas.arena import CodeArena, RoundStats |
9 | 9 | from codeclash.constants import RESULT_TIE |
10 | 10 |
|
| 11 | +DEFAULT_SIMS = 100 |
11 | 12 | MAP_EXT_TO_HEADER = { |
12 | 13 | "js": "function robot(state, unit) {", |
13 | 14 | "py": "def robot(state, unit):", |
@@ -66,15 +67,16 @@ def execute_round(self, agents: list[Player]): |
66 | 67 | # Submit all simulations to the thread pool |
67 | 68 | futures = [ |
68 | 69 | executor.submit(self._run_single_simulation, agents, idx, cmd) |
69 | | - for idx in range(self.game_config.get("sims_per_round", 100)) |
| 70 | + for idx in range(self.game_config.get("sims_per_round", DEFAULT_SIMS)) |
70 | 71 | ] |
71 | 72 |
|
72 | 73 | # Collect results as they complete |
73 | 74 | i_completed = 0 |
74 | 75 | for future in as_completed(futures): |
75 | 76 | future.result() |
76 | 77 | i_completed += 1 |
77 | | - self.logger.info(f"Completed {i_completed} of {len(futures)} simulations") |
| 78 | + if i_completed % 10 == 0: |
| 79 | + self.logger.info(f"Completed {i_completed} of {len(futures)} simulations") |
78 | 80 |
|
79 | 81 | def _get_winner_txt(self, output_file: str, agents: list[Player]) -> str: |
80 | 82 | try: |
@@ -114,7 +116,7 @@ def _get_winner_json(self, output_file: str, agents: list[Player]) -> str: |
114 | 116 |
|
115 | 117 | def get_results(self, agents: list[Player], round_num: int, stats: RoundStats): |
116 | 118 | winners = [] |
117 | | - for idx in range(self.game_config.get("sims_per_round", 100)): |
| 119 | + for idx in range(self.game_config.get("sims_per_round", DEFAULT_SIMS)): |
118 | 120 | output_file = self.log_round(round_num) / f"sim_{idx}.{self.sim_ext}" |
119 | 121 | if not output_file.exists(): |
120 | 122 | self.logger.warning(f"Simulation {idx} not found, skipping") |
|
0 commit comments