Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the option to prefer high/low rated players #865

Merged
merged 15 commits into from
Nov 20, 2023

Conversation

AttackingOrDefending
Copy link
Member

@AttackingOrDefending AttackingOrDefending commented Nov 4, 2023

The bot can now prefer high rated players, low rated players, or have no preference at all.
EDIT: Will fix the tests later.

closes #840

Copy link
Contributor

@mheinzel mheinzel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The feature seems useful to me, but I was wondering about some of the calculations.

Also, config options like this one (that have a few special values and everything else falls back to a default behavior) are always error-prone. I feel like it won't take long until someone has a typo in their config, e.g. "hihg", which just gets ignored silently.
Some similar fields have a check for this in config.py, see e.g. valid_pgn_grouping_options. So maybe it would be a good idea to do something similar for the rating preference.

I could also imagine this kind of check being done similarly to (or even as part of) set_config_default. Just as the default value, we could optionally list the valid values of each field, in a uniform declarative way. But that change might be better as a separate refactoring.

matchmaking.py Outdated Show resolved Hide resolved
"""Get the weight for each bot. A higher weights means the bot is more likely to get challenged."""
weights = [1] * len(online_bots)
if rating_preference == "high":
reduce_ratings_by = min(min_rating - (max_rating - min_rating), min_rating - 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does this calculation come from? Isn't min_rating - (max_rating - min_rating) just max_rating? Then min only really makes sense here in the case where min_rating > max_rating, which seems like it should never happen.

Maybe I'm missing something, but then a clarifying comment would be helpful for future readers.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This calculation is the same as 2*min_rating-max_rating. With this change, a bot with max_rating rating will be twice as likely to get picked as a bot with min_rating. I will add a comment.

@AttackingOrDefending
Copy link
Member Author

I will add checks for valid option values.

matchmaking.py Outdated Show resolved Hide resolved
@MarkZH MarkZH merged commit 7b5e08c into lichess-bot-devs:master Nov 20, 2023
15 checks passed
@AttackingOrDefending AttackingOrDefending deleted the rating-preference branch December 11, 2023 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make matchmaking time delay shorter
3 participants