Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ curl "http://localhost:5000/?fen=rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR%20w

This engine implements the UCI protocol and can be used as a bot on [Lichess](https://lichess.org). You can use the python bridge between Lichess Bot API and the engine: [https://github.com/ShailChoksi/lichess-bot](https://github.com/ShailChoksi/lichess-bot).

To run it as a bot you'll need to produce a python executable. [PyInstaller](https://pyinstaller.readthedocs.io/en/stable/) can produce it by running the following command:
To run it as a bot you'll need to produce a python executable. We use [PyInstaller](https://pyinstaller.readthedocs.io/en/stable/) via our Makefile:

```shell
python3 -m PyInstaller main.py
make build-lichess
```

This creates a `build` and `dist` folder. The `dist` folder contains the main executable in a folder called `main`. All the files inside `main` need to be copied over to `/lichess-bot/engines` for it to work. You can checkout [/lichess](lichess/README.md) for further lichess setup.
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,8 @@ install: venv activate
requirements.txt: pyproject.toml ensure-uv
uv pip compile pyproject.toml -o requirements.txt

build-lichess: ensure-uv
uv run pyinstaller moonfish/main.py --name moonfish --onefile --hidden-import chess --add-data "opening_book:opening_book"

clean:
rm -rf .venv __pycache__ .mypy_cache dist *.egg-info
rm -rf .venv __pycache__ .mypy_cache dist build *.egg-info *.spec
4 changes: 2 additions & 2 deletions lichess/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ To run the engine as a lichess bot you'll need to install the [Lichess Bot API](

If you pull [https://github.com/ShailChoksi/lichess-bot](https://github.com/ShailChoksi/lichess-bot) to the same parent directory of moonfish, such that your local setup looks like:

```bash
```shell
$ tree moonfish/ lichess-bot/ -L 1
moonfish/
├── LICENSE
Expand All @@ -20,6 +20,6 @@ you could then run the below to setup (build + move files) lichess to work with

don't forget to create a [`.env`](../.env.example) with your lichess API token (with bot:play scope)

```bash
```shell
lichess/setup_macos.sh
```
4 changes: 2 additions & 2 deletions lichess/setup_macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ source .env
read -p "Do you want to build a new binary? (y/n) " answer
answer=$(echo "$answer" | tr '[:upper:]' '[:lower:]')
if [[ "$answer" == "y" || "$answer" == "yes" ]]; then
python -m PyInstaller main.py --onefile
make build-lichess
fi

# fetch opening book if not already downloaded
Expand All @@ -39,7 +39,7 @@ brew install gettext
if [ -f ../lichess-bot/engines/main ]; then
rm ../lichess-bot/engines/main
fi
cp dist/main ../lichess-bot/engines/main
cp dist/moonfish ../lichess-bot/engines/main
mkdir -p ../lichess-bot/engines/opening_book
cp opening_book/cerebellum.bin ../lichess-bot/engines/opening_book/cerebellum.bin
bash .env
Expand Down
Loading