MCPcopy Create free account
hub / github.com/CodeClash-ai/CodeClash / get_results

Method get_results

codeclash/arenas/scml/scml.py:109–149  ·  view source on GitHub ↗
(self, agents: list[Player], round_num: int, stats: RoundStats)

Source from the content-addressed store, hash-verified

107 assert_zero_exit_code(response, logger=self.logger)
108
109 def get_results(self, agents: list[Player], round_num: int, stats: RoundStats):
110 result_file = self.log_round(round_num) / RESULTS_JSON
111 if not result_file.exists():
112 self.logger.error(f"Missing result file: {result_file}")
113 stats.winner = RESULT_TIE
114 for agent in agents:
115 stats.scores[agent.name] = CRASH_SCORE
116 stats.player_stats[agent.name].score = CRASH_SCORE
117 stats.details.append(
118 json.dumps(
119 {
120 "player": agent.name,
121 "score": CRASH_SCORE,
122 "status": "error",
123 "error": f"missing SCML result file: {result_file}",
124 },
125 sort_keys=True,
126 )
127 )
128 return
129
130 with open(result_file) as f:
131 result = json.load(f)
132
133 scores = {agent.name: 0.0 for agent in agents}
134 for player, score in result.get("average_scores", {}).items():
135 if player in scores:
136 scores[player] = float(score)
137
138 stats.scores = scores
139 stats.details = result.get("details", [])
140 for player, score in scores.items():
141 stats.player_stats[player].score = score
142
143 if not scores:
144 stats.winner = RESULT_TIE
145 return
146
147 top_score = max(scores.values())
148 winners = [player for player, score in scores.items() if score == top_score]
149 stats.winner = winners[0] if len(winners) == 1 else RESULT_TIE

Callers

nothing calls this directly

Calls 2

log_roundMethod · 0.80
getMethod · 0.80

Tested by

no test coverage detected