Skip to content

Commit c8a2bfd

Browse files
updates
1 parent 1881c1b commit c8a2bfd

3 files changed

Lines changed: 53 additions & 14 deletions

File tree

README.md

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,31 @@
1-
Environment Setup (Python 3.10+ Recommended)
1+
## Environment setup (Python 3.10+ recommended)
22
- Clone repo
33
- Open VSCode and go to the program folder
44
- Create a venv `python -m venv .venv`
55
- Enter the venv `.\.venv\Scripts\activate`
66
- Run `pip install -r requirements.txt`
77

8-
Lichess Connection:
8+
## Lichess connection
99
- Create an account on [Lichess.org](https://lichess.org/signup?referrer=https%3A%2F%2Flichess.org%2F)
1010
- 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.
1111
- 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.**
1212

1313
![lichess_pic_2](https://github.com/user-attachments/assets/03492f8e-0ae9-495d-9058-f14cc835c82a)
1414
![lichess_pic_3](https://github.com/user-attachments/assets/db262216-1559-4bbc-ac5e-39b83699bda6)
1515

16-
17-
1816
You can run a quick smoke test in a sample python file as in:
1917

2018
From the command line:
21-
```export lichess_token="YOUR_TOKEN"``` (in linux/max osx)
2219

23-
```set lichess_token="YOUR_TOKEN"``` (in Windows)
20+
```bash
21+
export lichess_token="YOUR_TOKEN"
22+
```
23+
(in Linux/macOS)
24+
25+
```powershell
26+
set lichess_token="YOUR_TOKEN"
27+
```
28+
(in Windows)
2429

2530
In a test_token.py file run:
2631
```
@@ -40,8 +45,45 @@ def smoke_test_token():
4045
smoke_test_token()
4146
```
4247

43-
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.
48+
## Upgrade to bot account
49+
After entering your token in the config.yml file, you can run the following command to upgrade your account to a bot account:
50+
```bash
51+
python lichess_bot.py -u
52+
```
53+
54+
If successful, this command will also start running your bot on lichess. Navigate to lichess.org. You should see a robot icon at the top left corner indicating that you are logged in as a bot. Press play against computer and run your bot in a test game, ensuring it is able to make moves. Your starting bot is a random move bot, so don't expect it to play well!
55+
56+
## Customize your bot
57+
Afterwards see the homemade.py file for sample chess engine classes. A template class called MyBot is provided for you to customize your own bot logic. Expand on the search method to implement your own chess engine logic. You may add any functions you need to the class.
58+
59+
The only file you should change is homemade.py. The other files are driver code that connects to lichess and handles all the API calls. The homemade.py file contains the bot class that you can customize.
60+
61+
## Run your bot for testing
62+
To run your bot, simply execute the following command:
63+
```bash
64+
python lichess_bot.py
65+
```
66+
67+
Or
68+
69+
```bash
70+
python lichess_bot.py -v
71+
```
72+
73+
If you want to see verbose logging output.
74+
75+
## Running your bot during the tournament
76+
77+
During tournament time we will be using the lichess GUI to send match challenges.
78+
79+
## Algorithms You Should Check Out
80+
### Minimax Search
81+
### Alpha-Beta Pruning
82+
### Iterative Deepening
83+
### Transposition Tables
4484

85+
## Recommended watching
86+
- Great video on chess engine development that covers some of the above algorithms in detail: https://www.youtube.com/watch?v=U4ogK0MIzqk&t=1008s (Note you can skip the parts that cover board representation and move generation since those are already implemented for you in this starter code).
4587

4688
## Citation
4789
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).

config.yml.default

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ url: "https://lichess.org/" # Lichess base URL.
33

44
engine: # Engine settings.
55
dir: "./engines/" # Directory containing the engine. This can be an absolute path or one relative to lichess-bot/.
6-
name: "engine_name" # Binary name of the engine to use.
6+
name: "MyBot" # Binary name of the engine to use.
77
# interpreter: "java"
88
# interpreter_options:
99
# - "-jar"
@@ -40,11 +40,11 @@ engine: # Engine settings.
4040
offer_draw_pieces: 10 # Only if the pieces on board are less than or equal to this value, the bot offers/accepts draw.
4141

4242
online_moves:
43-
max_out_of_book_moves: 10 # Stop using online opening books after they don't have a move for 'max_out_of_book_moves' positions. Doesn't apply to the online endgame tablebases.
43+
max_out_of_book_moves: 4 # Stop using online opening books after they don't have a move for 'max_out_of_book_moves' positions. Doesn't apply to the online endgame tablebases.
4444
max_retries: 2 # The maximum amount of retries when getting an online move.
4545
# max_depth: 10 # How many moves from the start to take from online books. Default is no limit.
4646
chessdb_book:
47-
enabled: false # Whether or not to use chessdb book.
47+
enabled: true # Whether or not to use chessdb book.
4848
min_time: 20 # Minimum time (in seconds) to use chessdb book.
4949
max_time: 10800 # Maximum starting game time (in seconds) to use chessdb book.
5050
move_quality: "good" # One of "all", "good", "best".
@@ -159,9 +159,6 @@ challenge: # Incoming challenges.
159159
time_controls: # Time controls to accept (bots are not allowed to play ultraBullet).
160160
- bullet
161161
- blitz
162-
- rapid
163-
- classical
164-
# - correspondence
165162
modes: # Game modes to accept.
166163
- casual # Unrated games.
167164
- rated # Rated games - must comment if the engine doesn't try to win.

homemade.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,4 +140,4 @@ def search(self, board: chess.Board, *args: HOMEMADE_ARGS_TYPE) -> PlayResult:
140140
"""
141141
# NOTE: This baseline keeps behavior simple and unchanged on purpose.
142142
# Replace this with your own logic (heuristics or a search algorithm).
143-
return PlayResult(random.choice(list(board.legal_moves)), None)
143+
return PlayResult(random.choice(list(board.legal_moves)))

0 commit comments

Comments
 (0)