| 10 | |
| 11 | |
| 12 | class ModelProfile: |
| 13 | def __init__(self, name: str): |
| 14 | self.name = name |
| 15 | self.steps = [] |
| 16 | self.failed_commands = 0 |
| 17 | self.failed_command_types = {} |
| 18 | self.tournaments = [] |
| 19 | |
| 20 | @property |
| 21 | def steps_per_round(self) -> float: |
| 22 | return sum(self.steps) / len(self.steps) if self.steps else 0.0 |
| 23 | |
| 24 | @property |
| 25 | def steps_total(self) -> int: |
| 26 | return sum(self.steps) |
| 27 | |
| 28 | @property |
| 29 | def cmd_failure_rate(self) -> float: |
| 30 | return self.failed_commands / sum(self.steps) if self.steps else 0.0 |
| 31 | |
| 32 | @property |
| 33 | def rounds_total(self) -> int: |
| 34 | return len(self.steps) |
| 35 | |
| 36 | @property |
| 37 | def tournament_count(self) -> Counter: |
| 38 | return Counter([t.split(".", 2)[1] for t in self.tournaments]) |
| 39 | |
| 40 | def __repr__(self): |
| 41 | return f"""Model: {self.name} |
| 42 | - Steps: {self.steps_total} (Total); {self.steps_per_round:.2f} (Per Round); |
| 43 | - Rounds played: {self.rounds_total} |
| 44 | - Failed cmds: {self.cmd_failure_rate:.2%} ({self.failed_commands}/{self.steps_total}) |
| 45 | - Most common failed command types: {Counter(self.failed_command_types).most_common(5)} |
| 46 | - Tournament count: {self.tournament_count.most_common(5)}""" |
| 47 | |
| 48 | |
| 49 | class TrajectoryAnalyzer: |