From 041dc69575c6333d133178e8d8738ba555b63357 Mon Sep 17 00:00:00 2001 From: "Giannis (Ioannis) Pantidis" <40605232+AttackingOrDefending@users.noreply.github.com> Date: Sun, 11 Aug 2024 01:04:08 +0300 Subject: [PATCH] Fix matchmaking bug with concurrency set to 0 (#1004) Fixes #1003 * Fix matchmaking bug with concurrency set to 0 * Add warning for setting concurrency equal to 0 --- lib/config.py | 3 +++ lib/matchmaking.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/config.py b/lib/config.py index 5285713fd..4f8b9c097 100644 --- a/lib/config.py +++ b/lib/config.py @@ -290,6 +290,9 @@ def validate_config(CONFIG: CONFIG_DICT_TYPE) -> None: config_assert(online_section.get("move_quality") != "suggest" or not online_section.get("enabled"), f"XBoard engines can't be used with `move_quality` set to `suggest` in {subsection}.") + config_warn(CONFIG["challenge"]["concurrency"] > 0, "With challenge.concurrency set to 0, the bot won't accept or create " + "any challenges.") + config_assert(CONFIG["challenge"]["sort_by"] in ["best", "first"], "challenge.sort_by can be either `first` or `best`.") config_assert(CONFIG["challenge"]["preference"] in ["none", "human", "bot"], "challenge.preference should be `none`, `human`, or `bot`.") diff --git a/lib/matchmaking.py b/lib/matchmaking.py index ed08608d6..ca499be2c 100644 --- a/lib/matchmaking.py +++ b/lib/matchmaking.py @@ -253,7 +253,7 @@ def challenge(self, active_games: set[str], challenge_queue: MULTIPROCESSING_LIS :param challenge_queue: The queue containing the challenges. :param max_games: The maximum allowed number of simultaneous games. """ - max_games_for_matchmaking = max_games if self.matchmaking_cfg.allow_during_games else 1 + max_games_for_matchmaking = max_games if self.matchmaking_cfg.allow_during_games else min(1, max_games) game_count = len(active_games) + len(challenge_queue) if (game_count >= max_games_for_matchmaking or (game_count > 0 and self.last_challenge_created_delay.time_since_reset() < self.max_wait_time)