Как создать своего бота?
Всем привет! Я решил сделать блог о том, как сделать своего бота, который умеет играть не только в стандартные виды шахмат, но и во варианты.
Нам понадобится: Windows, Python блокнот и папка BotLi-main.
Где это скачать?
Python: https://www.python.org/
Блокнот: подойдет любой блокнот, например системный блокнот на Windows либо Notepad++, который можно скачать тут: https://notepad-plus-plus.org/
BotLi-main: https://github.com/Torom/BotLi, нажимаете <> Code > Downolad ZIP. Если у вас скачался ZIP архив - его нужно превратить в обычную папку, а если сразу папка - то пошли дальше. К следующему шагу.
Создание токена: создаете новый ПУСТОЙ АККАУНТ и переходите по ссылке: https://lichess.org/account/oauth/token/create. Отмечаете все пункты И ОБЯЗАТЕЛЬНО СОХРАНЯЕТЕ ТОКЕН!!!
Присвоение титула бота: нажимаете Win+R > cmd > ok и пишите код ниже:
curl -H "Authorization: Bearer ТВОЙ_ТОКЕН" -d '' https://lichess.org/api/bot/account/upgrade
Главное впиши свой токен вместо ТВОЙ_ТОКЕН.
Проверяй, твой аккаунт уже стал ботом?
Настройка конфига: переходите в вашу папку BotLi-main и ищите файл config.yml.default, заходите в него и в первой строчке, где у вас написано:
token: "lip_********************"
Вместо lip_ и звездочек вставляете свой токен.
Пока что сохраняете файл и переименовываете его в config.yml БЕЗ .default
Далее самое интересное - скачивание движков.
Скачиваете: https://stockfishchess.org/ и https://github.com/ianfab/Fairy-Stockfish/releases/latest/download/fairy-stockfish-largeboard_x86-64.exe
Скачалось? Переноси файлы, именно файлы в папку engines.
Снова заходи в файл config.yml и с 3 строчки по 28 строчку ваш конфиг должен выглядеть так:
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.
silence_stderr: false # Suppresses stderr output.
move_overhead_multiplier: 1.0 # Increase if your bot flags games too often. Default move overhead is 1 second per 1 minute initital time.
uci_options: # Arbitrary UCI options passed to the engine.
Threads: 4 # Max CPU threads the engine can use.
Hash: 256 # Max memory (in megabytes) the engine can allocate.
Move Overhead: 150 # Increase if your bot flags games too often.
limits: # Limits that end the move calculation early.
## time: 5.0 # Max time per move in seconds.
## depth: 26 # Max depth per move.
## nodes: 4000000 # Max nodes per move.
variants: # Engine used for variants when no suitable special engine is configured.
dir: "./engines/fairy-stockfish.exe" # Directory containing the engine.
name: "variant_engine_executable" # Binary name of the engine to use.
ponder: true # Think on opponent's time.
silence_stderr: false # Suppresses stderr output.
move_overhead_multiplier: 1.0 # Increase if your bot flags games too often. Default move overhead is 1 second per 1 minute initital time.
uci_options: # Arbitrary UCI options passed to the engine.
Threads: 4 # Max CPU threads the engine can use.
Hash: 256 # Max memory (in megabytes) the engine can allocate.
Move Overhead: 150 # Increase if your bot flags games too often.
limits: # Limits that end the move calculation early.
Далее - запуск бота!
Снова открываете Win+R > cmd > ok и пишите команды по порядку:
cd и_путь_к_папке_BotLi
python
quit ()
pip3 install virtualenv
virtualenv .venv
.\.venv\scripts\activate
python user_interface.py
Готово! Ваш бот работает!
You may also like
Arseniy_Rybasov