Skip to content

Commit 514c510

Browse files
committed
Ref: Don't duplicate state, use property for scoreboard
1 parent 444198b commit 514c510

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

codeclash/tournaments/pvp_training.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ def __init__(
3030
for agent_conf in self.config["players"]:
3131
self.agents.append(self.get_agent(agent_conf, self.config["prompts"]))
3232
self.logger = get_logger(self.game.name)
33-
self.scoreboard: list[tuple[int, str]] = []
33+
34+
@property
35+
def scoreboard(self) -> list[tuple[int, str]]:
36+
return self._metadata.setdefault("scoreboard", [])
3437

3538
@property
3639
def rounds(self) -> int:

codeclash/tournaments/single_player_training.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717

1818
class SinglePlayerTraining(AbstractTournament):
19-
def __init__(self, config: dict, cleanup: bool = False):
19+
def __init__(self, config: dict, *, cleanup: bool = False):
2020
super().__init__(config, name="SinglePlayerTraining")
2121
self.cleanup_on_end = cleanup
2222
self.game: CodeGame = get_game(
@@ -28,7 +28,10 @@ def __init__(self, config: dict, cleanup: bool = False):
2828
mirror_agent_config = copy.deepcopy(self.config["player"])
2929
mirror_agent_config["name"] = "mirror"
3030
self.mirror_agent: Player = self.get_agent(mirror_agent_config, round=0)
31-
self.scoreboard: list[tuple[int, str]] = []
31+
32+
@property
33+
def scoreboard(self) -> list[tuple[int, str]]:
34+
return self._metadata.setdefault("scoreboard", [])
3235

3336
@property
3437
def rounds(self) -> int:

0 commit comments

Comments
 (0)