https://github.com/tailuge/bot-o-tron
Try out lichess' bot interface
https://github.com/tailuge/bot-o-tron
chess chess-engine javascript lichess lichess-api
Last synced: 4 months ago
JSON representation
Try out lichess' bot interface
- Host: GitHub
- URL: https://github.com/tailuge/bot-o-tron
- Owner: tailuge
- License: gpl-3.0
- Created: 2018-04-17T12:01:08.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2025-03-09T06:18:49.000Z (about 1 year ago)
- Last Synced: 2025-03-09T07:21:57.900Z (about 1 year ago)
- Topics: chess, chess-engine, javascript, lichess, lichess-api
- Language: JavaScript
- Homepage: https://bot-o-tron.onrender.com/
- Size: 699 KB
- Stars: 38
- Watchers: 6
- Forks: 25
- Open Issues: 33
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# bot-o-tron
[](https://sonarcloud.io/summary/new_code?id=tailuge_bot-o-tron)
[](https://codecov.io/gh/tailuge/bot-o-tron)
[](https://www.codefactor.io/repository/github/tailuge/bot-o-tron)
[](https://gitpod.io/#https://github.com/tailuge/bot-o-tron)
This project creates a simple chess bot using javascript that
connects to [lichess'](https://lichess.org)
bot interface .
This project can be hosted free on cloud providers such as [render.com](https://render.com).
* Play against this bot unrated now on lichess at [@bot-o-tron](https://lichess.org/@/bot-o-tron)
## Setup
* Get an [API token](https://lichess.org/account/oauth/token) from lichess.org
and add it as an environment variable on your machine or cloud hosting provider.
```bash
$ nvm use v18.16.1
$ yarn install
# Linux
$ export API_TOKEN=xxxxxxxxxx
# Windows
$ setx API_TOKEN xxxxxxxxxx
```
## Run
The project runs as an express node server that connects
to the lichess BOT account using the API_TOKEN
```bash
yarn start
```
## Local unit tests and code coverage
```bash
yarn test
```
To implement your chess bot you only need to create one class
that implements the method:
```js
getNextMove(moves) {
return uciMove;
}
```
Where moves is a list of moves so far in uci format e.g. `["e2e4", "b8c6", "f2f4"]`
See [`RandomPlayer`](src/bots/RandomPlayer.js) for minimal implementation
using [chess.js](https://github.com/jhlywa/chess.js/blob/master/README.md)
## Free Cloud Hosting
If you register a free render.com account you can host a BOT like this one
as is - just add your `API_TOKEN` to the environment property configuration.
This code auto deploys and is live at
[](https://render.com/deploy)
## Tournaments
Compare bots locally in a round-robin tournament
```bash
$ yarn tournament
Results
[ { player: 'AntiPatzerPlayer ', score: 32.5 },
{ player: 'PatzerPlayer ', score: 23 },
{ player: 'RandomPlayer ', score: 22.5 },
{ player: 'SwarmKingPlayer ', score: 18 } ]
```