Analyze scores per round for each competitor from round_stats in metadata.json. Scores are calculated as wins + 0.5*ties, same as in the table.
(self)
| 793 | return {"all_files": all_files_list, "line_counts_by_round": line_counts_by_round} |
| 794 | |
| 795 | def analyze_sim_wins_per_round(self) -> dict[str, Any]: |
| 796 | """Analyze scores per round for each competitor from round_stats in metadata.json. |
| 797 | Scores are calculated as wins + 0.5*ties, same as in the table.""" |
| 798 | metadata = self._get_metadata() |
| 799 | if not metadata.is_valid: |
| 800 | return {"players": [], "rounds": [], "scores_by_player": {}} |
| 801 | |
| 802 | round_stats = metadata.round_stats |
| 803 | # Collect all player names from all rounds |
| 804 | player_names = set() |
| 805 | for round_data in round_stats.values(): |
| 806 | scores = round_data.get("scores", {}) |
| 807 | player_names.update([k for k in scores.keys() if k != "Tie"]) |
| 808 | player_names = sorted(player_names) |
| 809 | |
| 810 | # Collect all round numbers (sorted) |
| 811 | round_nums = sorted([int(k) for k in round_stats.keys()]) |
| 812 | |
| 813 | # Build scores_by_player: {player: [scores_per_round]} |
| 814 | # Scores = (wins + 0.5*ties) / total_games * 100 (percentage, same as in process_round_results) |
| 815 | scores_by_player = {p: [] for p in player_names} |
| 816 | for round_num in round_nums: |
| 817 | round_data = round_stats.get(str(round_num), {}) |
| 818 | scores = round_data.get("scores", {}) |
| 819 | ties = scores.get("Tie", 0) |
| 820 | total_games = sum(scores.values()) |
| 821 | |
| 822 | for p in player_names: |
| 823 | wins = scores.get(p, 0) |
| 824 | if total_games > 0: |
| 825 | # Calculate score as percentage: (wins + 0.5*ties) / total_games * 100 |
| 826 | player_score = ((wins + 0.5 * ties) / total_games) * 100 |
| 827 | else: |
| 828 | player_score = 0 |
| 829 | scores_by_player[p].append(round(player_score, 1)) |
| 830 | |
| 831 | return { |
| 832 | "players": player_names, |
| 833 | "rounds": round_nums, |
| 834 | "scores_by_player": scores_by_player, |
| 835 | } |
| 836 | |
| 837 | def load_matrix_analysis(self) -> dict[str, Any] | None: |
| 838 | """Load and process matrix.json if it exists""" |
no test coverage detected