About this project
Polyfish is an AI project built around the award-winning strategy game Polytopia. It recreates the entire game in Rust and TypeScript, then applies a hybrid Monte Carlo Tree Search (MCTS) and neural network approach inspired by Alpha-Zero. The system trains through self-play, with frozen-anchor Elo measurement tracking strength over time.
Core components include a Rust game engine and AI backend (polyfish-rs), a Vite/React web frontend (polyfish-ui), and a separate C++ memory reader (polyfish-reader) that injects into the Steam version of Polytopia to extract live game states as JSON. A C# BepInEx/PolyMod alternative (polyfish-mod) auto-plays replays inside the real game and posts captured states to the local server.
The AI architecture uses a Gumbel Alpha-Zero search variant for self-play, a PUCT-based MCTS, and a ResNet-style network (PolyZeroNet) with cross-attention and decomposed policy heads mapping moves across action type, source, target, and option. GameState encoding feeds 11x11 feature maps into the network.
Three inference backends read the same model.safetensors format: Candle (default, GPU-capable), libtorch/MPS for macOS, and a hand-composed MPSGraph backend optimized for Apple silicon. Batching layers fan leaf evaluations from multiple actors onto the selected backend.
The web interface provides both an interactive game simulator (served at localhost:3000) and a live training dashboard showing loss charts, move distribution, and value histograms. Setup requires Rust, Node, and Python 3; the frontend builds once and the Rust server serves both the backend and static assets.
Open work tracks training pipeline improvements, registered experiments with verdicts, and search/learning-signal reviews. The main bottleneck remains compute requirements for effective network training.
Comments
0 Rating appears after 10 ratings
Sign in to join the discussion.