Skip to content

Commit

Permalink
Fix matchmaking bug with concurrency set to 0 (lichess-bot-devs#1004)
Browse files Browse the repository at this point in the history
Fixes lichess-bot-devs#1003

* Fix matchmaking bug with concurrency set to 0

* Add warning for setting concurrency equal to 0
  • Loading branch information
AttackingOrDefending authored Aug 10, 2024
1 parent 7c1b614 commit 041dc69
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`.")
Expand Down
2 changes: 1 addition & 1 deletion lib/matchmaking.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 041dc69

Please sign in to comment.