Even if you already have a Lichess account, I suggest you to create a new one, whose username will be the name of the BOT. It is worth noting that if you already had a Lichess account you should use a different email for the bot account. Go here to create the Lichess account that will be used for your BOT.
After this, you have to choose the software that will be used to connect your PC to the server. There are many implementations, but the one I highly recommend is this one: BotLi as it is highly customizable, it lets you run different engines per color and time control, specific books per color and time control, online opening explorer, ChessDB, SyzygyTB...
So firstly, either download the code from the BotLi github repository or git clone it to the folder you want to have the BOT in your PC. BotLi only supports Python3.10 or higher, so if you have an older version you should update it.
After downloading the code, unzip it in your folder of preference, it should look like this:
In order to continue, you should now create the personal API Access Token of your BOT. This is very important as it is the way the BOT has to authenticate and login into the server. To do this, login into your newly created BOT account, click on your username, then on preferences and scroll down to Personal API access tokens. Click on the "+" symbol, give a name to your token and enable the necessary permissions, in particular you must enable the "Play with the BOT API" one (bot:play). for example:
After you click on create your token will be generated, it is highly advisable to save it somewhere in a secure way. Do not share your token with anyone and try to keep it as safe as possible, because if anyone gets access to your token it will have access directly to your account, so be careful!
Now its time to start configuring the BOT:
1. Go to the unzipped BotLi folder and place the engine and the opening book / books in the "engines" folder
2. Use a code editor such a Notepad++ to modify the config.yml.default file
Some steps to do this:
- Open the config.yml.default file with a code editor and start by replacing the XXX.. in the token section with your newly created token, then continue configuring the UCI options, SyzygyPaths and the book / books you want to use in the book section. For example:
This would be the corresponding code to run Stockfish with 8 threads, 1024MB of Hash, 1000 Move Overhead and configure 5 man Syzygy Tablebases:
Code: Select all
engines:
standard: # Engine used for standard chess and when no suitable special engine is configured.
dir: "./engines" # Directory containing the engine.
name: "stockfish.exe" # Binary name of the engine to use.
ponder: true # Think on opponent's time.
use_syzygy: true # Whether the engine should be configured to use syzygy.
silence_stderr: false # Suppresses stderr output.
uci_options: # Arbitrary UCI options passed to the engine. (Commenting allowed)
Threads: 8 # Max CPU threads the engine can use.
Hash: 1024 # Max memory (in megabytes) the engine can allocate.
Move Overhead: 1000 # Increase if your bot flags games too often.
syzygy:
enabled: true # Activate local syzygy endgame tablebases.
paths: # Paths to local syzygy endgame tablebases.
- "C:/3-4-5"
max_pieces: 5 # Count of max pieces in the local syzygy endgame tablebases.
instant_play: true # Whether the bot should play directly from syzygy without engine if possible.
Code: Select all
opening_books:
enabled: true # Activate opening books.
priority: 400 # Priority with which this move source is used. Higher priority is used first.
books:
standard_white:
selection: weighted_random # Move selection is one of "weighted_random", "uniform_random" or "best_move".
names:
- "WhiteBook1"
- "WhiteBook2"
standard_black:
selection: best_move # Move selection is one of "weighted_random", "uniform_random" or "best_move".
names:
- "BlackBook1"
- "BlackBook2"
In the challenge section of the config file you should decide what challenges you want your bot to accept, imagine you want the bot to play from bullet to classical, with a minimum time control of 60s+0 seconds increment to a maximum of 30 minutes+ 5seconds increment, it would look like this:
Code: Select all
challenge: # Incoming challenges. (Commenting allowed)
concurrency: 1 # Number of games to play simultaneously.
bullet_with_increment_only: false # Whether bullet games against BOTs should only be accepted with increment.
# min_increment: 0 # Minimum amount of increment to accept a challenge.
max_increment: 5 # Maximum amount of increment to accept a challenge.
min_initial: 60 # Minimum amount of initial time to accept a challenge.
max_initial: 1800 # Maximum amount of initial time to accept a challenge.
variants: # Chess variants to accept (https://lichess.org/variant).
- standard
# - chess960
# - fromPosition
# - antichess
# - atomic
# - crazyhouse
# - horde
# - kingOfTheHill
# - racingKings
# - threeCheck
time_controls: # Speeds or time controls in initial_minutes+increment_seconds format to accept.
- bullet
- blitz
- rapid
- classical
bot_modes: # Game modes to accept against BOTs.
# - casual # Unrated games.
- rated # Rated games
human_modes: # Game modes to accept against humans.
# - casual # Unrated games.
# - rated # Rated games
Code: Select all
matchmaking:
delay: 120 # Time in seconds the bot must be idle before a new challenge is started.
timeout: 30 # Time until a challenge is canceled.
types: # Matchmaking types of which one is randomly selected before each game.
bullet: # Arbitrary name of the matchmaking type. Names must be unique.
tc: 1+1 # Time control in initial_minutes+increment_seconds format.
rated: true # Whether matchmaking should play rated games.
variant: standard # Chess variant (https://lichess.org/variant) to challenge.
weight: 40 # Weight with which this type is selected. (Default: 100)
multiplier: 20 # Multiplier for calculating timeouts in matchmaking. Higher values lead to a wider range of opponents.
max_rating_diff: 200
blitz: # Arbitrary name of the matchmaking type. Names must be unique.
tc: 3+0 # Time control in initial_minutes+increment_seconds format.
rated: true # Whether matchmaking should play rated games.
variant: standard # Chess variant (https://lichess.org/variant) to challenge.
weight: 35 # Weight with which this type is selected. (Default: 100)
multiplier: 20 # Multiplier for calculating timeouts in matchmaking. Higher values lead to a wider range of opponents.
max_rating_diff: 200
rapid: # Arbitrary name of the matchmaking type. Names must be unique.
tc: 8+0 # Time control in initial_minutes+increment_seconds format.
rated: true # Whether matchmaking should play rated games.
variant: standard # Chess variant (https://lichess.org/variant) to challenge.
weight: 25 # Weight with which this type is selected. (Default: 100)
multiplier: 20 # Multiplier for calculating timeouts in matchmaking. Higher values lead to a wider range of opponents.
max_rating_diff: 250
To finish with the config, modify the book paths and names according to the book section you previously modified, for example:
Code: Select all
books: # Names of the opening books (to be used above in the opening_books section) and paths to the opening books.
WhiteBook1: "C:/BotLi/engines/wbook1.bin"
WhiteBook2: "C:/BotLi/engines/wbook2.bin"
BlackBook1: "C:/BotLi/engines/blackbook1.bin"
BlackBook2: "C:/BotLi/engines/blackbook2.bin"
The last step is to start the bot, upgrade it to BOT account, run it in matchmaking mode and start playing (remember you need Python3.10 at least). To do that:
1. Launch a CMD / Terminal in the BotLi folder
2. Type-> python -m pip install -r requirements.txt
3. Run the bot in matchmaking mode-> python user_interface.py -m
To simplify that you can create an script that does it all with just double-clicking it, it looks like this:
Code: Select all
python -m pip install -r requirements.txt
cls
python user_interface.py -m