| 146 | and pool every recorded game into one readable ``trace.md``. The raw XML is deleted |
| 147 | afterwards so it never bloats the logs shipped to the competing agents.""" |
| 148 | super().copy_logs_from_env(round_num) |
| 149 | round_dir = self.log_round(round_num) |
| 150 | summaries = [] |
| 151 | for xml in sorted(round_dir.glob("record_*.xml")): |
| 152 | match = re.search(r"record_(\d+)\.xml", xml.name) |
| 153 | if not match: |
| 154 | continue |
| 155 | try: |
| 156 | summaries.extend(process_record(xml, round_dir, int(match.group(1)), SIMS_PER_RUN)) |
| 157 | except Exception as e: |
| 158 | self.logger.warning(f"Failed to distill RoboCode sims from {xml.name}: {e}") |
| 159 | finally: |
| 160 | xml.unlink(missing_ok=True) |
| 161 | if summaries: |
| 162 | try: |
| 163 | write_aggregate_trace(round_dir, summaries, self.game_config.get("sims_per_round", 100)) |
| 164 | except Exception as e: |
| 165 | self.logger.warning(f"Failed to write aggregate RoboCode trace: {e}") |
| 166 | |