Skip to content

About

Superhuman AlphaZero-style Quoridor engine: batched MCTS in Rust, honest self-play training. Play it & analyze your games at claustrophobia.dev

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

Claustrophobia

A superhuman Quoridor engine — AlphaZero-style self-play training, a batched MCTS in Rust, and a browser UI to play against it. The walls close in; hence the name.

Strength: trained entirely from self-play (no human or external-engine data), it defeats the strongest publicly playable Quoridor AIs we could find, including Ka at full search and Zero-Ink at maximum thinking time.


Play against it in 10 minutes

Zero-install option: play it right now at claustrophobia.dev — the hosted engine, plus analysis tools for reviewing your games.

Prefer to run it locally? You need: a PC with a reasonably modern NVIDIA GPU (CPU works too, just slower), ~5 GB of disk.

1. Install the two toolchains

Then install PyTorch (the engine links against its libtorch under the hood):

pip install torch --index-url https://download.pytorch.org/whl/cu128

(CPU-only machine? Use pip install torch instead.)

2. Get the code and the trained network

git clone https://github.com/Plaaasma/Claustrophobia.git
cd Claustrophobia

Download champion.pt from the latest release and save it as:

webapp/champion.pt

3. Build

set LIBTORCH_USE_PYTORCH=1        (Windows cmd;  PowerShell: $env:LIBTORCH_USE_PYTORCH="1";  Linux/mac: export LIBTORCH_USE_PYTORCH=1)
cargo build --release --features nn

First build takes a few minutes. If the build can't find torch, make sure the pip install torch above went into the same Python that's first on your PATH.

4. Run the web app

Windows (PowerShell) — the torch DLLs must be on PATH:

$env:PATH = "$(python -c 'import torch,os;print(os.path.dirname(torch.__file__))')\lib;" + $env:PATH
$env:QUORIDOR_CHECKPOINT = "webapp\champion.pt"
$env:QUORIDOR_DEVICE = "gpu"          # or "cpu"
.\target\release\webserve.exe

Linux / macOS:

export LD_LIBRARY_PATH="$(python -c 'import torch,os;print(os.path.dirname(torch.__file__))')/lib:$LD_LIBRARY_PATH"
QUORIDOR_CHECKPOINT=webapp/champion.pt QUORIDOR_DEVICE=gpu ./target/release/webserve

5. Play

Open http://127.0.0.1:8080 in your browser. Pick a side, pick a strength (the "Opponent lvl" presets go from intuition — instant, raw-network moves — to long — deep search), and play. Leave the sims box empty to use the presets; type a number there for an exact search budget.

That's it.


What's in the box

Path What it is
src/ The engine: bitboard game rules, batched virtual-loss MCTS (tree reuse, FPU, MCTS-solver, transposition eval cache, Gumbel root search), self-play, SPRT gating, training orchestration (tch/libtorch), TensorRT inference backend
src/bin/webserve.rs The HTTP/browser server you just ran
src/bin/play.rs Terminal play + analysis CLI
src/bin/train_loop.rs The full AlphaZero loop: self-play → train → gated promotion
python/ Network definition, distributed pretraining (pretrain_ddp.py), Weights & Biases logging bridge, opening-book generator
webapp/ Browser UI + optional WebSocket bridges to third-party engines (Ka, Titanium, Zero-Ink, Ishtar) for sparring
configs/ Training run configurations (kv format, every key documented inline)
ka/ Harness for benchmarking against the open-source Ka engine locally
runs/openings/ Opening books (model-generated and human-frequency)

Training your own network

The short version (see configs/production8.kv for every knob):

# 1. (optional) pretrain on existing self-play data across 2 nodes:
python python/pretrain_ddp.py     # see the file header for env vars

# 2. run the full self-play loop (starts from scratch or from a checkpoint):
./target/release/train_loop configs/production8.kv

The loop plays games against itself, trains a challenger network, and promotes it only when it beats the champion under an SPRT gate plus win-rate floors against a pool of frozen anchor networks — a defense against the self-play Elo inflation that plagues naive gated setups. An external sentinel (games vs. a fixed third-party engine) keeps the whole curve honest.

Design notes worth reading if you're building something similar: the value target mixes bootstrapped root values with discounted game outcomes (q_mix, value_discount — the discount teaches the engine to win fast, which prevents late-game shuffling), and self-play openings are seeded from a book regenerated from the current champion after every promotion.

Requirements in one place

  • Rust (stable), Python 3.10–3.12, PyTorch ≥ 2.x (LIBTORCH_USE_PYTORCH=1 makes the Rust side link against pip's torch)
  • --features nn for everything neural; --features nn-trt adds the TensorRT backend (NVIDIA only, used for the self-play farm)
  • No network weights are committed to the repo — grab them from Releases

Credits

  • Ka (sugiyama2718) and Titanium (titaniummachine1) — open-source opponents used for benchmarking, via the included bridges
  • The AlphaZero, KataGo and Leela Chess Zero papers/projects, whose training tricks are liberally borrowed throughout

License

MIT — see LICENSE.

About

Superhuman AlphaZero-style Quoridor engine: batched MCTS in Rust, honest self-play training. Play it & analyze your games at claustrophobia.dev

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages