An AI NN + MCTS Rust capable of playing the award winning Polytopia strategy game.
- Replica Simulation: I painstakingly rebuilt the entire Polytopia game logic in Typescript, then translated it to Rust for performance and AI training.
- Web UI: Mimicry of the original game's UI, fully interactive and served by the Rust backend.
- AI Engine: A hybrid MCTS (Monte Carlo Tree Search) + Neural Network (Alpha-Zero style) approach.
- Game RIPPER: C++ injection script that extracts live game states from the Steam version of Polytopia.
- Need monster compute to train the NN.
- Elo rating system.
- Install Rust, Python 3, and CMake.
- Run
./run-server.sh(Initializes backend on port 3000). - Open
http://localhost:3000in your browser.
polyfish-rs/local_setup.sh: Set up the Python virtual environment and dependencies (candle,numpy,safetensors).polyfish-rs/run_training_loop.sh: Launch the self-play and training cycle.polyfish-rs/train.py: The PyTorch/Candle-compatible training script.
polyfish-rs/: The Rust-based game engine and AI agent.src/public/: The modern Web UI frontend (JS/HTML/CSS).polyfish-scraper/: Utilities for gathering game data and assets.polyfish-reader/: The C++ game state extraction suite.notes.md/notes-heuristics.md: Architectural research and evaluation logic documentation.
polyfish-rs/src/ai/mcts_zero.rs: Core Alpha-Zero style MCTS implementation.polyfish-rs/src/ai/network.rs: Candle-powered Neural Network architecture.polyfish-rs/src/ai/evaluator/: Modular logic for Economy, Military, and Expansion evaluation.polyfish-rs/src/ai/heuristic_mcts.rs: Lightweight MCTS using heuristics for UI analysis.polyfish-rs/src/ai/book.rs: Opening move library for standardized tribe starts.polyfish-rs/src/ai/features.rs: Logic for encoding GameState into NN tensors.
polyfish-reader/polyfish-reader.cpp: C++ memory reader that extracts live game state for the simulator.polyfish-reader/inputerv2: Interactive tool for manipulating live game memory.polyfish-reader/polyfish-scanner.cpp: Utility for finding memory offsets in new game versions. TO