Skip to content

Rowan441/StarterLichessBot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Starter Lichess Bot

🤖 A Customizable Python Chess Bot

📝 Table of Contents

🧐 About

This is a simple python script that listens to the Event stream for a Lichess.org BOT account and accepts/rejects challenges, plays games using fully customizable engine, responds to users in the game's chat.

There is already a sample chessbot implementation RandomMoveBot() which randomly plays a legal move.

This project was made using berserk-downstream. A client library for the Lichess API

🎈 Try it out

Check out my BOT account you can play against here.

🏁 Getting Started

Prerequisite

Make sure you have a Lichess account that you have upgraded to a BOT account and created a PAT for your account

Installing

First clone the repository:

git clone https://github.com/Rowan441/WeirdChessBot.git

Then install virtualenv if you don't already have it:

pip install virtualenv

cd into the project directory and create a virtual environment:

virtualenv .venv

Activate the virtual enironment:

On windows:

.venv\Scripts\activate

On Unix / MacOS:

source .venv/bin/activate

Finally install the required libraries:

pip install -r requirements.txt

API Token

Important: you need to create a file named api.token in the root directory of the project add your BOT account's Personal API token to the file

echo YOURAPITOKEN > api.token

🏃 Usage

To run the project make sure you have a Lichess account that you have upgraded to a BOT account and added your API token to a api.token file

Run the starterlichessbit.py file with optional --logfile flag:

starterlichessbot.py
OR
starterlichessbot.py --logfile ..\logs.txt  

🔨 Build Your Own Bot

You can create your own Bots. In this program, a Bot is defined as a class that implements: getBestMove(self, gameState, variant) and getResponseToMessage(self, chatLine) methods

Checkout the ChessBotInterface() class in the chessbots.py file for the specific details of the getBestMove and getResponseToMessage functions. You can create subclasses from ChessBotInterface() and override its methods with your own funcitonality.

Once you have a working bot you can tell the program to use it by:

  1. Importing the bot in starterlichessbot.py:
 8|  from chessbots import MyBotClass # Import your bot
  1. instantiating the bot on line 17 of starterlichessbot.py
19|  bot = MyBotClass()

In the source code this has already been done with RandomChessBot, so just replace RandomChessBot with your bot class.

⛏️ Built Using

✍️ Authors

About

A Simple Python Chess Bot that plays on Lichess.com

Topics

Resources

Stars

Watchers

Forks

Languages