AttackingOrDefending / lidraughts-bot

A bridge between Lidraughts API and draughts engines
GNU Affero General Public License v3.0
7 stars 10 forks source link
bot bot-account checkers draughts lidraughts lidraughts-api lidraughts-bot python

lidraughts-bot

Python Build Python Test CodeQL

A bridge between Lidraughts Bot API and bots.

How to Install

Mac/Linux:

Windows:

Heroku:

Lidraughts OAuth

Setup Engine

Within the file config.yml:

As an optional convenience, there is a folder named engines within the lidraughts-bot folder where you can copy your engine and all the files it needs. This is the default executable location in the config.yml.default file.

Engine Configuration

Besides the above, there are many possible options within config.yml for configuring the engine for use with lidraughts-bot.

One last option is go_commands. Beneath this option, arguments to the Hub level command can be passed. For example,

  go_commands:
    movetime: 1000

will send level move-time=1000 to inform the engine on the time it should use.

Lidraughts Upgrade to Bot Account

WARNING: This is irreversible. Read more about upgrading to bot account.

To Run

After activating the virtual environment created in the installation steps (the source line for Linux and Macs or the activate script for Windows), run

python3 lidraughts-bot.py

The working directory for the engine execution will be the lidraughts-bot directory. If your engine requires files located elsewhere, make sure they are specified by absolute path or copy the files to an appropriate location inside the lidraughts-bot directory.

To output more information (including your engine's thinking output and debugging information), the -v option can be passed to lidraughts-bot:

python3 lidraughts-bot.py -v

If you want to record the output to a log file, add the -l or --logfile along with a file name:

python3 lidraughts-bot.py --logfile log.txt

To Quit

Creating a homemade bot

As an alternative to creating an entire draughts engine and implementing one of the communication protocols (Hub or DXP), a bot can also be created by writing a single class with a single method. The search() method in this new class takes the current board and the game clock as arguments and should return a move based on whatever criteria the coder desires.

Steps to create a homemade bot:

  1. Do all the steps in the How to Install
  2. In the config.yml, change the engine protocol to homemade
  3. Create a class in some file that extends MinimalEngine (in strategies.py).
    • Look at the strategies.py file to see some examples.
    • If you don't know what to implement, look at the EngineWrapper or HubEngine class.
      • You don't have to create your own engine, even though it's an "EngineWrapper" class.
        The examples just implement search.
  4. In the config.yml, change the name from engine_name to the name of your class

    • In this case, you could change it to:

      name: "RandomMove"

Tips & Tricks

[Service] Environment="PYTHONUNBUFFERED=1" ExecStart=/usr/bin/python3 /home/attackingordefending/lidraughts-bot/lidraughts-bot.py WorkingDirectory=/home/attackingordefending/lidraughts-bot/ User=attackingordefending Group=attackingordefending Restart=always

[Install] WantedBy=multi-user.target



# Acknowledgements
Thanks to the Lichess Team for creating a [repository](https://github.com/ShailChoksi/lichess-bot) that could be easily modified to a format that supports Lidraughts. Thanks to [RoepStoep](https://github.com/RoepStoep) for running an [API](https://lidraughts.org/api) to communicate with the BOTs. Thanks to [AttackingOrDefending](https://github.com/AttackingOrDefending) and his [pydraughts](https://github.com/AttackingOrDefending/pydraughts) code which allows engine communication seamlessly.

# License
lidraughts-bot is licensed under the AGPLv3 (or any later version at your option). Check out the [LICENSE file](/LICENSE) for the full text.