项目作者: tailuge

项目描述 :
Try out lichess' bot interface
高级语言: JavaScript
项目地址: git://github.com/tailuge/bot-o-tron.git
创建时间: 2018-04-17T12:01:08Z
项目社区:https://github.com/tailuge/bot-o-tron

开源协议:GNU General Public License v3.0

下载


bot-o-tron

Code Smells
codecov
CodeFactor
Open in Gitpod

This project creates a simple chess bot using javascript that
connects to lichess’
bot interface https://lichess.org/api#tag/Bot .
This project can be hosted free on cloud providers such as render.com.

  • Play against this bot unrated now on lichess at @bot-o-tron

Setup

  • Get an API token from lichess.org
    and add it as an environment variable on your machine or cloud hosting provider.
  1. $ nvm use v18.16.1
  2. $ yarn install
  3. # Linux
  4. $ export API_TOKEN=xxxxxxxxxx
  5. # Windows
  6. $ setx API_TOKEN xxxxxxxxxx

Run

The project runs as an express node server that connects
to the lichess BOT account using the API_TOKEN

  1. yarn start

Local unit tests and code coverage

  1. yarn test

To implement your chess bot you only need to create one class
that implements the method:

  1. getNextMove(moves) {
  2. return uciMove;
  3. }

Where moves is a list of moves so far in uci format e.g. ["e2e4", "b8c6", "f2f4"]

See RandomPlayer for minimal implementation
using chess.js

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://bot-o-tron.onrender.com

Deploy to Render

Tournaments

Compare bots locally in a round-robin tournament

  1. $ yarn tournament
  2. Results
  3. [ { player: 'AntiPatzerPlayer ', score: 32.5 },
  4. { player: 'PatzerPlayer ', score: 23 },
  5. { player: 'RandomPlayer ', score: 22.5 },
  6. { player: 'SwarmKingPlayer ', score: 18 } ]