Skip to content

Commit c18322a

Browse files
committed
Add details field for clarifications
1 parent f62f395 commit c18322a

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

codeclash/games/game.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def __init__(self, round_num: int, agents: list[Player]):
3838
# Map of player to game metric (e.g. # of wins, assets accumulated)
3939
self.scores: dict[str, float] = {}
4040
self.player_stats: dict[str, PlayerStats] = {agent.name: PlayerStats(name=agent.name) for agent in agents}
41+
self.details: list[str] = []
4142

4243
def __str__(self) -> str:
4344
rv = [f"In round {self.round_num}, the winner is {self.winner}.", "\nSummary of player performance:"]
@@ -46,6 +47,8 @@ def __str__(self) -> str:
4647
rv.append(f"- {player}: submission compiled successfully, score={stats.score}")
4748
else:
4849
rv.append(f"- {player}: submission failed with error: {stats.invalid_reason}")
50+
if self.details:
51+
rv.extend(["Details:"] + [f"- {line}" for line in self.details])
4952
return "\n".join(rv)
5053

5154
def to_dict(self) -> dict[str, Any]:
@@ -54,6 +57,7 @@ def to_dict(self) -> dict[str, Any]:
5457
return {
5558
"round_num": self.round_num,
5659
"winner": self.winner,
60+
"details": self.details,
5761
"scores": {name: self.scores.get(name, 0.0) for name in player_names},
5862
"player_stats": {name: stats.to_dict() for name, stats in self.player_stats.items()},
5963
}

codeclash/games/robotrumble/robotrumble.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ def get_results(self, agents: list[Player], round_num: int, stats: RoundStats):
8989

9090
# Update stats
9191
stats.winner = final_winner
92+
stats.details.append(f"In this round, {agents[0].name} was Blue and {agents[1].name} was Red.")
9293
stats.scores = dict(counts)
9394
for player, score in counts.items():
9495
if player != RESULT_TIE:

0 commit comments

Comments
 (0)