|
1 | | -<div align="center"> |
| 1 | +Environment Setup: |
| 2 | +- Clone repo |
| 3 | +- Open VSCode and go to the program folder |
| 4 | +- Create a venv `python -m venv .venv` |
| 5 | +- Enter the venv `.\.venv\Scripts\activate` |
| 6 | +- Run `pip install -r requirements.txt` |
2 | 7 |
|
3 | | -  |
| 8 | +Lichess Connection: |
| 9 | +- Create an account on [Lichess.org](https://lichess.org/signup?referrer=https%3A%2F%2Flichess.org%2F) |
| 10 | +- Hover over your name in top right, then select `Preferences`->`API access tokens`->`Click the blue button top right to create a token, give your token a name (ex: lichess-bot-token), select all the permissions then click `Create`. Save this token to the config.yml under the token key. **Note to set all the option values of the bot to Green to ensure maximum compatibility. Remember to save your token and do NOT share it or hardcode it in your code.** |
4 | 11 |
|
5 | | - <h1>lichess-bot</h1> |
| 12 | + |
| 13 | + |
6 | 14 |
|
7 | | - A bridge between [lichess.org](https://lichess.org) and bots. |
8 | | - <br> |
9 | | - <strong>[Explore lichess-bot docs »](https://github.com/lichess-bot-devs/lichess-bot/wiki)</strong> |
10 | | - <br> |
11 | | - <br> |
12 | | - [](https://github.com/lichess-bot-devs/lichess-bot/actions/workflows/python-build.yml) |
13 | | - [](https://github.com/lichess-bot-devs/lichess-bot/actions/workflows/python-test.yml) |
14 | | - [](https://github.com/lichess-bot-devs/lichess-bot/actions/workflows/mypy.yml) |
15 | 15 |
|
16 | | -</div> |
17 | 16 |
|
18 | | -## Overview |
| 17 | +You can run a quick smoke test in a sample python file as in: |
19 | 18 |
|
20 | | -[lichess-bot](https://github.com/lichess-bot-devs/lichess-bot) is a free bridge |
21 | | -between the [Lichess Bot API](https://lichess.org/api#tag/Bot) and chess engines. |
| 19 | +From the command line: |
| 20 | +```export lichess_token = "YOUR_TOKEN"``` |
22 | 21 |
|
23 | | -With lichess-bot, you can create and operate a bot on lichess. Your bot will be able to play against humans and bots alike, and you will be able to view these games live on lichess. |
| 22 | +In a test_token.py file run: |
| 23 | +``` |
| 24 | +TOKEN = os.environ["lichess_token"] |
| 25 | +H = { |
| 26 | + "Authorization": f"Bearer {TOKEN}", |
| 27 | + "Accept": "application/x-ndjson", |
| 28 | +} |
24 | 29 |
|
25 | | -See also the lichess-bot [documentation](https://github.com/lichess-bot-devs/lichess-bot/wiki) for further usage help. |
| 30 | +# Smoke Test for |
| 31 | +def smoke_test_token(): |
| 32 | + global TOKEN |
| 33 | + H = {"Authorization": f"Bearer {TOKEN}"} |
| 34 | + me = requests.get("https://lichess.org/api/account", headers=H).json() |
| 35 | + print("Logged in as:", me["username"]) |
26 | 36 |
|
27 | | -## Features |
28 | | -Supports: |
29 | | -- Every variant and time control |
30 | | -- UCI, XBoard, and Homemade engines |
31 | | -- Matchmaking (challenging other bots) |
32 | | -- Offering Draws and Resigning |
33 | | -- Participating in tournaments |
34 | | -- Accepting move takeback requests from opponents |
35 | | -- Saving games as PGN |
36 | | -- Local & Online Opening Books |
37 | | -- Local & Online Endgame Tablebases |
| 37 | +smoke_test_token() |
| 38 | +``` |
38 | 39 |
|
39 | | -Can run on: |
40 | | -- Python 3.9 and later |
41 | | -- Windows, Linux and MacOS |
42 | | -- Docker |
| 40 | +Afterwards see the homemady.py file for sample chess engine classes, for which you will subclass your own, namely from the MinimalEngine class from the LichessBot/lib/engine_wrapper.py file. |
43 | 41 |
|
44 | | -## Steps |
45 | | -1. [Install lichess-bot](https://github.com/lichess-bot-devs/lichess-bot/wiki/How-to-Install) |
46 | | -2. [Create a lichess OAuth token](https://github.com/lichess-bot-devs/lichess-bot/wiki/How-to-create-a-Lichess-OAuth-token) |
47 | | -3. [Setup the engine](https://github.com/lichess-bot-devs/lichess-bot/wiki/Setup-the-engine) |
48 | | -4. [Configure lichess-bot](https://github.com/lichess-bot-devs/lichess-bot/wiki/Configure-lichess-bot) |
49 | | -5. [Upgrade to a BOT account](https://github.com/lichess-bot-devs/lichess-bot/wiki/Upgrade-to-a-BOT-account) |
50 | | -6. [Run lichess-bot](https://github.com/lichess-bot-devs/lichess-bot/wiki/How-to-Run-lichess%E2%80%90bot) |
51 | | - |
52 | | -## Advanced options |
53 | | -- [Create a homemade engine](https://github.com/lichess-bot-devs/lichess-bot/wiki/Create-a-homemade-engine) |
54 | | -- [Add extra customizations](https://github.com/lichess-bot-devs/lichess-bot/wiki/Extra-customizations) |
55 | | - |
56 | | -<br /> |
57 | | - |
58 | | -## Acknowledgements |
59 | | -Thanks to the Lichess team, especially T. Alexander Lystad and Thibault Duplessis for working with the LeelaChessZero team to get this API up. Thanks to [Niklas Fiekas](https://github.com/niklasf) and his [python-chess](https://github.com/niklasf/python-chess) code which allows engine communication seamlessly. |
60 | | - |
61 | | -## License |
62 | | -lichess-bot is licensed under the AGPLv3 (or any later version at your option). Check out the [LICENSE file](https://github.com/lichess-bot-devs/lichess-bot/blob/master/LICENSE) for the full text. |
63 | 42 |
|
64 | 43 | ## Citation |
65 | 44 | If this software has been used for research purposes, please cite it using the "Cite this repository" menu on the right sidebar. For more information, check the [CITATION file](https://github.com/lichess-bot-devs/lichess-bot/blob/master/CITATION.cff). |
0 commit comments