lichess-bot-devs / lichess-bot

A bridge between Lichess bots and chess engines
GNU Affero General Public License v3.0
765 stars 448 forks source link

Contributing a few features I implemented #494

Closed mheinzel closed 2 years ago

mheinzel commented 2 years ago

Hi!

Thanks for creating this project! It made it super easy to set up my bot and now it already played more than 2000 games on Lichess. :star_struck:

I also extended the code to tweak it to my needs and I think some features could be useful to others as well: https://github.com/ShailChoksi/lichess-bot/compare/master...mheinzel:lichess-bot:master Before opening a bunch of PRs, I wanted to ask you whether you want them in the first place. At the moment, the changes are kind of intertwined and specific to my needs, but I'd be happy to open separate PRs for each feature you want, make changes you deem useful and also add some documentation.

What I implemented:

  1. Randomly choosing between multiple matchmaking choices As already explained in https://github.com/ShailChoksi/lichess-bot/pull/493#issuecomment-1175459973
  2. Explicitly handle hitting the rate limit for the challenge API (HTTP 429) There was something about the code about not raising an exception no unsuccessful API calls, but then the response didn't contain any JSON, so it ended with a stack trace, requiring to restart the bot. This is now handled more explicitly (although there is still room for improvement I think) and receiving a 429 will lead to a 1h matchmaking pause, after which matchmaking resumes.
  3. Add challenge blocklist, allowing to exclude opponents from matchmaking Some bots didn't accept my challenges for various reasons (e.g. they only play humans, (un)rated, specific time controls or variants), so the bot often needed 2-3 challenges to play a game. This quickly depleted the allowed 400 challenges/day. To avoid this, I checked the logs after a day or two and manually added some opponents to the blocklist. This helped a lot.
  4. Do not challenge bots with 0 games in this game type/variant This does not make the previous feature obsolete, but in many cases where bots only play e.g. bullet and blitz, they won't have any rapid and classical games. Or an antichess bot had no regular chess games at all. Not challenging them in these cases reduced my blocklist quite a bit. Seems useful to me, but maybe there should be a way to turn it off in the config?
  5. Do not challenge bots that violated the Terms of Service As I understand, you don't get rating from them anyways? I wanted to exclude them, but this could be turned into a config flag as well.
  6. A few small changes to documentation and what is logged.

Which of these are you interested in?

AttackingOrDefending commented 2 years ago
mheinzel commented 2 years ago

Cool, then I'll make a few PRs later this week.

  • I thought that line 70 covered this

I think what happens is that games is 0, but there is still a provisional rating of 2000.

MarkZH commented 2 years ago

We look forward to your PRs.