From 36d5aa30fc4c54c11775782f25d006c2cac996f8 Mon Sep 17 00:00:00 2001 From: Bram van den Heuvel Date: Wed, 1 Jul 2026 21:54:24 +0200 Subject: [PATCH] Restrict participation to clients that want to participate --- agents/remote.py | 10 ++++++++++ elo_tracker/app.py | 9 +++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/agents/remote.py b/agents/remote.py index 5e32957..8eb61ce 100644 --- a/agents/remote.py +++ b/agents/remote.py @@ -20,6 +20,7 @@ class RemoteAgent(Agent): """ url : str + games : set[str] def __init__(self, url : str, timeout : float = 1.0) -> None: """ @@ -57,6 +58,8 @@ class RemoteAgent(Agent): profile=content, ) + self.games = set() + games = content.get("games") if isinstance(games, dict): if "tic-tac-toe" in games: @@ -64,6 +67,13 @@ class RemoteAgent(Agent): on_move=lambda x : self.poll("tic-tac-toe", "", x), profile=games["tic-tac-toe"], ) + if "royal-game-of-ur" in games: + self.add_royal_game_of_ur( + on_move=lambda x : self.poll("royal-game-of-ur", "", x), + profile=games["royal-game-of-ur"], + ) + + self.games = set(games.keys()) def get_action(self, game: str, action: str | None) -> Callable[[dict[str, Any]], dict[str, Any]] | None: """ diff --git a/elo_tracker/app.py b/elo_tracker/app.py index 82f436e..a33ba13 100644 --- a/elo_tracker/app.py +++ b/elo_tracker/app.py @@ -452,7 +452,12 @@ class EloTracker: self.load_players() with self.__lock: - available = len(self.players) + players = [ + player for player in self.players + if game.game_name() in player.games + ] + + available = len(players) if available < player_count: self.__debug( @@ -461,7 +466,7 @@ class EloTracker: ) else: self.__debug( - "Playing a new scheduled match" + f"Playing a new scheduled match of {game.game_name()}" ) self.play_random_match(game=game, player_count=player_count) except Exception as exc: