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

Function main

codeclash/analysis/viz/round_score_distribution.py:173–224  ·  view source on GitHub ↗

Calculate normalized scores and plot histograms stratified by game and by model.

(log_dir: Path)

Source from the content-addressed store, hash-verified

171
172
173def main(log_dir: Path) -> None:
174 """Calculate normalized scores and plot histograms stratified by game and by model."""
175 logger.info(f"Processing tournaments from {log_dir}")
176
177 scores_by_game = {}
178 scores_by_model = {}
179
180 for metadata_path in tqdm(list(log_dir.rglob("metadata.json"))):
181 try:
182 game_name, game_scores, model_scores = get_normalized_scores(metadata_path)
183 if game_name:
184 # Collect by game
185 for game, scores in game_scores.items():
186 if game not in scores_by_game:
187 scores_by_game[game] = []
188 scores_by_game[game].extend(scores)
189
190 # Collect by model
191 for model, scores in model_scores.items():
192 if model not in scores_by_model:
193 scores_by_model[model] = []
194 scores_by_model[model].extend(scores)
195 except Exception as e:
196 logger.error(f"Error processing {metadata_path}: {e}", exc_info=True)
197 continue
198
199 if not scores_by_game:
200 logger.warning("No scores collected")
201 return
202
203 all_scores = [s for scores in scores_by_game.values() for s in scores]
204 logger.info(
205 f"Collected {len(all_scores)} normalized scores across {len(scores_by_game)} games and {len(scores_by_model)} models"
206 )
207
208 # Plot by game
209 output_by_game = ASSETS_DIR / "round_score_distribution_by_game.pdf"
210 plot_stratified(
211 scores_by_game,
212 output_by_game,
213 title="Distribution of Normalized Player Scores by Game (Valid Rounds Only)",
214 by_model=False,
215 )
216
217 # Plot by model
218 output_by_model = ASSETS_DIR / "round_score_distribution_by_model.pdf"
219 plot_stratified(
220 scores_by_model,
221 output_by_model,
222 title="Distribution of Normalized Player Scores by Model (Valid Rounds Only)",
223 by_model=True,
224 )
225
226
227if __name__ == "__main__":

Callers 1

Calls 2

get_normalized_scoresFunction · 0.85
plot_stratifiedFunction · 0.70

Tested by

no test coverage detected