Skip to content

Commit a4a409b

Browse files
committed
Update RoundStats __str__
1 parent 33cd041 commit a4a409b

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

codeclash/games/game.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,13 @@ def __init__(self, round_num: int, agents: list[Player]):
3939
self.player_stats: dict[str, PlayerStats] = {agent.name: PlayerStats(name=agent.name) for agent in agents}
4040

4141
def __str__(self) -> str:
42-
return "\n".join([f"- Winner: {self.winner}", f"- Scores: {self.scores}"])
42+
rv = [f"In round {self.round_num}, the winner is {self.winner}.", "\nSummary of player performance:"]
43+
for player, stats in self.player_stats.items():
44+
if stats.valid_submit:
45+
rv.append(f"- {player}: submission compiled successfully, score={stats.score}")
46+
else:
47+
rv.append(f"- {player}: submission failed with error: {stats.invalid_reason}")
48+
return "\n".join(rv)
4349

4450
def to_dict(self) -> dict[str, Any]:
4551
result = {

codeclash/tournaments/pvp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def run(self) -> None:
7171
def run_competition_phase(self, round_num: int) -> None:
7272
# Run the game round and get results
7373
stats = self.game.run_round(self.agents, round_num)
74-
self.logger.info(f"Round {round_num}:\n{stats}")
74+
self.logger.info(stats)
7575

7676
# Create directory for round logs
7777
(self.game.log_local / "rounds" / str(round_num)).mkdir(parents=True, exist_ok=True)

codeclash/tournaments/single_player.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def run_training_round(self, round_num: int) -> None:
8484
"""Execute a single training round, i.e., run the game, then run the agent."""
8585
# Run the game round and get results
8686
stats = self.game.run_round([self.agent, self.mirror_agent], round_num)
87-
self.logger.info(f"Round {round_num}:\n{stats}")
87+
self.logger.info(stats)
8888

8989
# Write log to file
9090
results_file = self.game.log_local / "rounds" / str(round_num) / FILE_RESULTS

0 commit comments

Comments
 (0)