Skip to content

Latest commit

 

History

History
91 lines (71 loc) · 5.85 KB

README.md

File metadata and controls

91 lines (71 loc) · 5.85 KB

Lishogi Bot

Python Build Lishogi Bots

A bridge between Lichess API and Lishogi USI Bots. In case you don't know English, view the Japanese Translation here (日本語翻訳).

How to Install

Mac/Linux:

  • NOTE: Only Python 3.7 or later is supported!
  • Download the repo into Lishogi-Bot directory.
  • Navigate to the directory in cmd/Terminal: cd Lishogi-Bot.
  • Install pip: apt install python3-pip.
  • Install virtualenv: pip install virtualenv.
  • Setup virtualenv: apt install python3-venv.
python3 -m venv venv  # if this fails you probably need to add Python3 to your PATH.
virtualenv .venv -p python3  # if this fails you probably need to add Python3 to your PATH.
source ./venv/bin/activate
python3 -m pip install -r requirements.txt

Windows:

  • NOTE: Only Python 3.7 or later is supported!
  • If you don't have Python, you may download it here. When installing it, enable add Python to PATH, then go to custom installation (this may be not necessary, but on some computers it won't work otherwise) and enable all options (especially install for all users), except the last . It's better to install Python in a path without spaces, like C:\Python\.
  • To type commands it's better to use PowerShell. Go to Start menu and type PowerShell.
  • Then you may need to upgrade pip. Execute python -m pip install --upgrade pip in PowerShell.
  • Download the repo into lishogi-bot directory.
  • Navigate to the directory in PowerShell: cd [folder's adress] (like cd C:\shogi\lishogi-bot).
  • Install virtualenv: pip install virtualenv.
  • Setup virtualenv:
python -m venv .venv  # if this fails you probably need to add Python to your PATH.
./.venv/Scripts/Activate.ps1  # .\.venv\Scripts\activate.bat should work in cmd in administator mode. This may not work on Windows, and in this case you need to execute "Set-ExecutionPolicy RemoteSigned" first and choose "Y" there (you may need to run Powershell as administrator). After you executed the script, change execution policy back with "Set-ExecutionPolicy Restricted" and pressing "Y").
pip install -r requirements.txt

Lishogi OAuth

  • Create an account for your bot on Lishogi.org.
  • NOTE: If you have previously played games on an existing account, you will not be able to use it as a bot account.
  • Once your account has been created and you are logged in, create a personal OAuth2 token with the "Play games with the bot API" ('play:bot' scopes) selected and a description added.
  • A token e.g. xxxxxxxxxxxxxxxx will be displayed. Store this in config.yml as the token field.
  • NOTE: You won't see this token again on Lishogi, so save it or store it somewhere.

Setup Engine

  • Place your engine(s) in the engine.dir directory
  • In your config.yml file, enter the binary name as the engine.name field.
  • Using this process any engine can be added to the bot.
  • Note: The engine you add has to be running under the USI protocol, then only it will work

Lishogi Upgrade to Bot Account

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

  • run python lishogi-bot.py -u
  • for more verbrose logs run python lishogi-bot.py -v

Tips & Tricks

  • You can specify a different config file with the --config argument.
  • Here's an example systemd service definition:
[Unit]
Description=Lishogi-Bot
After=network-online.target
Wants=network-online.target

[Service]
Environment="PYTHONUNBUFFERED=1"
ExecStart=/usr/bin/python3/home/User/Lishogi-Bot/Lishogi-Bot.py
WorkingDirectory=/home/User/lishogi-bot/
User=UserName
Group=GroupName
Restart=always

[Install]
WantedBy=multi-user.target

Acknowledgements

Thanks to the Lichess Team for creating a repository that could be easily accessed and modified to help converting it to a format that supports Lishogi and for running an API which is used by lishogi. Thanks to the Tasuku SUENAGA a.k.a. gunyarakun and his python-shogi code which allows engine communication seamlessly. Thanks to WandererXII for all his effort and help.