| 10 | |
| 11 | |
| 12 | def compute_win_rates(folder_list): |
| 13 | wins = defaultdict(int) |
| 14 | total = defaultdict(int) |
| 15 | |
| 16 | for folder in folder_list: |
| 17 | metadata = json.load(open(folder / "metadata.json")) |
| 18 | |
| 19 | # Count wins per round |
| 20 | for round_key, round_data in metadata["round_stats"].items(): |
| 21 | if round_key == "overall": |
| 22 | continue |
| 23 | winner = round_data.get("winner") |
| 24 | for player in round_data.get("scores", {}).keys(): |
| 25 | total[player] += 1 |
| 26 | if player == winner: |
| 27 | wins[player] += 1 |
| 28 | |
| 29 | return {player: wins[player] / total[player] if total[player] > 0 else 0 for player in total.keys()} |
| 30 | |
| 31 | |
| 32 | def analyze_opponent_code_access(folder_list): |