AlphaZero-style Battlesnake training and serving in Rust.
| Path | What |
|---|---|
crates/snek-core |
Rules engine, standard board setup, observation encoding. |
crates/snek-search |
Simultaneous-move decoupled-PUCT MCTS. |
crates/snek-tch |
Libtorch/tch policy+value network used by training and serving. |
crates/snek-train |
Rust training binary plus realtime API for the frontend. |
crates/snek-server |
Battlesnake /move API server using the same tch network/checkpoint format. |
frontend |
Standalone Vite/React dashboard. |
archived |
Previous Python trainer/dashboard/bindings kept for reference during the port. |
The trainer is a standalone crate so ordinary workspace tests do not need to link libtorch. It owns self-play, training, checkpointing, and the dashboard API.
make train START=1 RUN_ID=devThe API listens on 127.0.0.1:8050 by default.
Key routes:
| Route | Purpose |
|---|---|
GET /api/stream/stats |
protobuf StatsFrame over SSE, base64 encoded |
GET /api/state |
current run state |
GET/POST /api/config |
training knobs |
POST /api/control/start |
start or resume a run |
POST /api/control/stop |
graceful stop and checkpoint |
GET /api/runs |
list run directories |
Run state is written under runs/<run-id>/:
config.json
trainer_state.json
net.safetensors
buffer/gen_*.json
metrics.jsonl
The replay buffer is restored from buffer/ on resume.
make frontendVite proxies /api to the trainer on port 8050. Production builds are written
to frontend/dist:
make frontend-buildThe trainer, network crate, and Battlesnake server use tch. For the current
development setup, reuse the installed PyTorch libtorch:
export LIBTORCH_USE_PYTORCH=1
export LIBTORCH_BYPASS_VERSION_CHECK=1The Makefile applies those variables for trainer and serving build/run targets.
A fully standalone libtorch install can be used by setting LIBTORCH instead.
make test # top-level Rust tests
make train # build and run snek-train
make frontend # Vite dev server
make frontend-build # static frontend build
make api # Battlesnake /move server
make fmt
make lint