Giter Club home page Giter Club logo

botli-1's Introduction

Overview

BotLi is a bot for Lichess. It connects any UCI engine with the Lichess Bot API.

It has a customizable support of Polyglot opening books, a variety of supported online opening books and an online endgame tablebase. It can query local Syzygy and Gaviota endgame tablebases.

In addition, BotLi can autonomously challenge other bots in any variants. It optionally supports two separate engines, one for standard chess and chess960 and one for Lichess chess variants.

How to install

  • NOTE: Only Python 3.10 or later is supported!
  • Download the repo into BotLi directory: git clone https://github.com/Torom/BotLi.git
  • Navigate to the directory in cmd/Terminal: cd BotLi
  • Copy config.yml.default to config.yml

Install all requirements:

python -m pip install -r requirements.txt
  • Customize the config.yml according to your needs.

Lichess OAuth

Setup Engine

Within the file config.yml:

  • Enter the directory containing the engine executable in the engine: dir field.
  • Enter the executable name in the engine: name field.
  • You need to adjust the settings in engine: uci_options depending on your system.

Setup opening book

To use an opening book, you have to enter a name of your choice and the path to the book at the end of the config in the books section.

In the upper engine: opening_books: books section you only have to enter the name you just chose. In addition, different books can be used for white, black and chess960. If no specific book is defined, the standard books are used.

For example, the books section could look like this:

books:
  Goi: "./engines/Goi.bin"
  Perfect: "/home/Books/Perfect2021.bin"
  Cerebellum: "Cerebellum.bin"

A corresponding engine: opening_books: section could look like this:

  opening_books:
    enabled: true
    books:
      white:
        - "Perfect"
        - "Goi"
#     black:
#       - "BlackBook"
      standard:
        - "Cerebellum" 
#     chess960:
#       - "Chess960Book"
    selection: "weighted_random"

How to control

Interactive mode

In this mode the bot is controlled by commands entered into the console.

Start

To start the bot, type:

python user_interface.py

The bot automatically accepts challenges. Which challenges are accepted is defined in the config in the section challenge.

To see all commands, type:

help

Matchmaking

To challenge other players with similar ratings, type:

matchmaking

Change the settings in matchmaking in the config to change how this bot challenges other players. The bot will pause matchmaking for incoming challenges. To exit the matchmaking mode type:

stop

To exit the bot completely, type:

quit

The bot will always wait until the current game is finished.

Non interactive mode

This mode is used automatically when BotLi is used without an interactive terminal, for example as a service. In this case, the bot is controlled by setting flags at start time.

Matchmaking

To let the bot challenge other bots in non interactive mode, start it like this:

python user_interface.py --matchmaking

CAUTION: Lichess will rate limit you if you let matchmaking run too long without adjusting the delay accordingly.

Upgrade to Bot account

When the bot is running in interactive mode it will ask for an account upgrade if necessary.

In non interactive mode the --upgrade flag must be set at start.

python user_interface.py --upgrade

The account cannot have played any game before becoming a Bot account. The upgrade is irreversible. The account will only be able to play as a Bot.

Running with Docker

The project comes with a Dockerfile, this uses Ubuntu 22.04, installs all dependencies, downloads the latest version of Stockfish and starts the bot.

If Docker is used, all configurations must be done in config.yml.default. This is automatically renamed to config.yml in the build process.

The Dockerfile also contains all commands to download Fairy-Stockfish and all NNUEs needed for the Lichess chess variants. These commands must be uncommented if desired. In addition, the variants engine must be enabled in the config.yml.default. To use NNUE for the Lichess chess variants the following UCI option for Fairy-Stockfish must be set in the config: EvalFile: "3check-313cc226a173.nnue:antichess-689c016df8e0.nnue:atomic-2cf13ff256cc.nnue:crazyhouse-8ebf84784ad2.nnue:horde-28173ddccabe.nnue:kingofthehill-978b86d0e6a4.nnue:racingkings-636b95f085e3.nnue"

Running as a service

This is an example systemd service definition:

[Unit]
Description=BotLi
After=network-online.target
Wants=network-online.target

[Service]
Environment="PYTHONUNBUFFERED=1"
ExecStart=/usr/bin/python3 /home/ubuntu/BotLi/user_interface.py
WorkingDirectory=/home/ubuntu/BotLi
User=ubuntu
Group=ubuntu
Restart=always

[Install]
WantedBy=multi-user.target

If the service should run with matchmaking the --matchmaking flag must be appended at the end of the ExecStart line.

Note: If you want the bot to run in matchmaking mode for a long time, it is recommended to set the matchmaking delay higher to avoid problems with the Lichess rate limit. I recommend the following formula: delay = 430 - 2 * initial_time - 160 * increment

Acknowledgements

Thanks to the Lichess team, especially T. Alexander Lystad and Thibault Duplessis for working with the LeelaChessZero team to get this API up. Thanks to the Niklas Fiekas and his python-chess code which allows engine communication seamlessly. In addition, the idea of this bot is based on ShailChoksi/lichess-bot.

License

BotLi is licensed under the AGPLv3 (or any later version at your option). Check out the LICENSE file for the full text.

botli-1's People

Contributors

torom avatar dependabot[bot] avatar bknox83 avatar venujasb avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.