# AIChessGM Leela Setup Package

This package contains the parts of the Leela-on-Vast/Home-Linux workflow that were created for this project and are safe to redistribute as part of the AIChessGM website package.

This package is intended to help you set up:

- a Vast.ai Linux GPU instance running `lc0` behind Tailscale
- a home Linux GPU server running `lc0` behind Tailscale
- a Mac client running AIChessGM
- a Windows or macOS machine building/running the Leela bridge from source
- a Windows client running Tailscale and connectivity checks

## What is included

- `LEELA_VASTAI_SETUP_GUIDE.md`
  - end-to-end setup instructions
- `src/`
  - Go source for `uci-bridge` plus startup/build scripts
- `vast/up.sh`
  - startup script for Vast container-style environments; auto-installs `tailscale` on fresh Jupyter containers when needed
- `vast/entrypoint.sh`
  - Docker/container entrypoint used by this project
- `linux/uci-bridge-linux`
  - Linux x86_64 UCI bridge binary from this project
- `examples/engine_profiles.cloud.example.conf`
  - example multi-engine cloud profile file
- `examples/lc0-cloud.service.example`
  - example `systemd` service for a home Linux host
- `DOWNLOAD_THESE_YOURSELF.md`
  - list of items you must download separately

## What is not included

- `lc0`
- network weights
- Tailscale installers
- Go toolchain
- AIChessGM app builds

Those components should be downloaded from their official sources.

## Quick-start recommendation

If you are new to this workflow:

1. Install Tailscale on your Mac or Windows machine.
2. Read `LEELA_VASTAI_SETUP_GUIDE.md`.
3. Use `vast/up.sh` if you are setting up a Vast.ai container workflow.
4. Use `examples/lc0-cloud.service.example` if you are setting up a home Linux `systemd` workflow.
5. If your Leela host is Windows, macOS, or a non-Linux Linux target, build the bridge from `src/`.
6. Download `lc0`, weights, Tailscale, and Go from the official sources listed in `DOWNLOAD_THESE_YOURSELF.md`.

## Build from source

The included `linux/uci-bridge-linux` binary is only for Linux x86_64.

If you want to run the bridge on another host OS, build it from `src/`:

```bash
cd src
go build -o uci-bridge-linux ./cmd/uci-bridge
GOOS=windows GOARCH=amd64 go build -o uci-bridge-windows-amd64.exe ./cmd/uci-bridge
GOOS=darwin GOARCH=arm64 go build -o uci-bridge-darwin-arm64 ./cmd/uci-bridge
```

Use the output that matches the machine running `lc0`.

## Safety note

This package assumes you are comfortable editing hostnames, auth keys, paths, and weights locations before running scripts. Linux container and `systemd` examples are included because those are the main deployment paths, but the bridge source itself is portable.
