Skip to content

Commit d81b9cf

Browse files
committed
Fix(pvp): Run last evaluation after agent updates are done
1 parent 2404276 commit d81b9cf

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

codeclash/tournaments/pvp.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,13 @@ def run(self) -> None:
6868
"""Main execution function that runs all rounds."""
6969
try:
7070
for round_num in range(1, self.rounds + 1):
71+
self.run_evaluation(round_num)
7172
self.run_training_round(round_num)
73+
self.run_evaluation(self.rounds + 1)
7274
finally:
7375
self.end()
7476

75-
def run_training_round(self, round_num: int) -> None:
76-
"""Execute a single training round."""
77+
def run_evaluation(self, round_num: int) -> None:
7778
# Run the game round and get results
7879
record = self.game.run_round(self.agents)
7980

@@ -89,9 +90,10 @@ def run_training_round(self, round_num: int) -> None:
8990
round_log_path = self.game.log_local / "rounds" / str(round_num) / f"sim_{idx}.log"
9091
round_log_path.write_text(lo)
9192
results_file = self.game.log_local / "rounds" / str(round_num) / "results.json"
92-
with open(results_file, "w") as f:
93-
json.dump(record.stats.model_dump(), fp=f, indent=2)
93+
results_file.write_text(json.dumps(record.stats.model_dump(), indent=2))
9494

95+
def run_training_round(self, round_num: int) -> None:
96+
"""Execute a single training round."""
9597
# Copy log to agent environments
9698
for agent in self.agents:
9799
self.logger.info(f"Copying round {round_num} log(s) to {agent.name}'s container...")
@@ -120,8 +122,7 @@ def run_agent(self, agent: Player, round_num: int) -> None:
120122

121123
def end(self) -> None:
122124
"""Save output files, clean up game resources and push agents if requested."""
123-
with open(self.local_output_dir / "metadata.json", "w") as f:
124-
json.dump(self.get_metadata(), fp=f, indent=2)
125+
(self.local_output_dir / "metadata.json").write_text(json.dumps(self.get_metadata(), indent=2))
125126
self.game.end(self.cleanup_on_end)
126127
if self.push_agent:
127128
for agent in self.agents:

codeclash/viewer/templates/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ <h2>📊 Game Results</h2>
4646

4747
<!-- Main Log Foldout -->
4848
<details class="foldout">
49-
<summary>📝 Game Log</summary>
49+
<summary>📝 Tournament Log</summary>
5050
<div class="log-content">
5151
<pre><code>{{ metadata.main_log }}</code></pre>
5252
</div>

0 commit comments

Comments
 (0)