← All work
AI · Reinforcement learning

Slime-Go

A 4-player territorial strategy engine exploring AlphaZero-style RL and slime-mold transport networks. Neural agents plan inside a compressed continuous spatial field.

TypeScript Private repo
Slime-Go Banner

Slime-Go: Neural Territorial Fields & Latent Spatial Dynamics

Slime-Go is a fast, highly optimized 4-player, non-zero-sum territorial strategy game and neural simulation environment. It explores the intersection of Deep Reinforcement Learning (AlphaZero/MuZero) and Ecological Transport Networks (such as Physarum polycephalum / Slime Mold diffusion).

Unlike traditional 2-player zero-sum variants, Slime-Go features emergent coalition pressure, leader suppression, and dynamic borderline softening. To master this environment, the ecosystem relies on Latent Spatial Dynamics, a neural architecture that detaches Monte Carlo Tree Search (MCTS) from explicit physical game engines and instead plans entirely inside a compressed continuous spatial field.


Core Features

  • Four-Player Dynamics: Support for 2, 3, or 4 players on the same board, radically augmenting traditional Go strategies into a fluid, non-zero-sum political landscape.
  • Neural & Heuristic Agents: Watch algorithms battle it out or jump in yourself against AI personalities (Territorial, Opportunist, Pacifist, Random) that adapt dynamically to the board state.
  • Three Gameplay Modes:
    • Autoplay: Act as a spectator while 4 AI agents evolve the board. Uncap the simulation speed to push hardware to its limit.
    • Play AI: Take control of Black and fight a 1v3 battle against the Neural Network.
    • Multiplayer: Connect with human opponents via real-time Socket.io signaling.
  • Algorithmic Field Overlays: Toggle between physical stones, calculated Heuristic Territory bounding, and pure continuous Neural Field prediction maps.
  • Tournament Dashboard: Visually monitor the multi-agent evaluating league where 24 seat-permutations are run completely in parallel headless threads to measure model variance and Absolute Utility ($U$).
  • Uncapped Physics Engine: Decouple React's render thread from the underlying state engine. Move slider to UNCAPPED to compute thousands of logical ticks per second, batching layout renders to eliminate UI bottlenecks.

How the AI Learns (Training Pipeline)

Slime-Go is not hardcoded with Go strategy; it discovers it from scratch using a continuous Reinforcement Learning pipeline. The AI improves via an autonomous closed-loop system:

  1. Self-Play Data Generation (MCTS): The engine runs continuous simulated background matches where the current best network plays against itself across all 4 colors. It explores the vast decision space using Monte Carlo Tree Search (MCTS), guided directly by its own neural predictions.
  2. Experience Replay Buffer: Every state transition, action probability, and final game outcome (both win/loss $v$ and fine-grained territorial margins) from these self-play games is saved to a decentralized better-sqlite3 database.
  3. Weight Optimization (Backpropagation): The internal TensorFlow.js backend periodically samples mini-batches of randomized historical games from the Replay Buffer. It computes the gradient loss across three specialized neural heads:
    • Policy Head: Did the raw neural network predict the move that the rigorous MCTS search ultimately discovered was best?
    • Value Head: Did the network accurately predict the final score/outcome of the game from the current position?
    • Spatial Field Head: Did the network correctly anticipate where the physical territorial boundaries would eventually harden? The weights are then adjusted via Stochastic Gradient Descent to minimize these prediction errors.
  4. League Promotion Check: The newly trained "Candidate" model is detached and sent to the Tournament Dashboard. It plays parallelized validation matches against the prevailing "Champion" model and non-learning heuristic anchors. If its mathematically calculated Absolute Utility ($U$) score is significantly higher, it overwrites the Champion and is promoted as the new baseline for all future self-play, closing the loop.

The 7 Phases of Implementation

1. Grounded Evaluation Leagues

We dismantled standard 1v1 Elo loops in favor of a 24-seat Multi-Agent Evaluator. The neural network proves its strength by competing against RANDOM, TERRITORIAL, OPPORTUNIST, and PACIFIST non-learning heuristic constraints. Fitness is measured via mathematical rank mapping $J(M)$ rather than binary win rates.

2. Neural Territorial Fields

The network goes beyond predicting Moves $(p)$ and Value $(v)$ by outputting a continuous Territorial Probability Field $(I)$. A secondary $L_{field}$ Mean Squared Error node actively trains the model to anticipate where territory will coalesce, structurally predicting long-term spatial ownership and projecting it directly into the UI.

3. Tournament Evaluation Protocol

The LeagueEvaluator provides headless, parallelized permutations of 24-seat layouts to stress-test standard deviation, extracting absolute $U$ metric consistency and $Var_{seat}(U)$ metrics, eliminating positional bias from the training pipeline.

4. Learned Spatial Physics Engine (Ecology)

Inspired by slime-mold adaptive transport models, the network accepts future-state configurations $I_{t+1}$ to learn local gradient operators $\nabla^2 I_p$, emulating formal Reaction-Diffusion equations. The FieldSimulator.ts forces the engine to unroll predictions into continuous $t+15$ animations viewable via the "Evolve Field" UI.

5. Latent Spatial Dynamics Engine (MuZero)

The core architecture has been successfully transitioned to a Latent Inference paradigm consisting of three models:

  • Representation Model ($E_\theta$): Encodes the physical board into a dense Latent Spatial Matrix.
  • Dynamics Model ($G_\theta$): Calculates state-transition mathematically $h_{k+1} = G_\theta(h_k, a_k)$, bypassing physical resolution entirely.
  • Prediction Model ($D_\theta$): Decodes Latent State $h_k$ into Policy, expected Value, and spatial Territorial fields ($I_k$). The MCTS algorithm now simulates its forward projections natively within this learned spatial representation.

6. Deep UI/UX Polish

The user interface has been rigorously engineered to seamlessly support the underlying complexity:

  • Pure CSS Tooltips: Tooltips have been stripped of JavaScript DOM measurement overhead, utilizing hardware-accelerated group-hover CSS classes to float cleanly and instantly over the application layout without starving the React render thread during intense simulations.
  • Accordion Modularity: The Left Sidebar configuration dashboards collapse dynamically via a global control state manager, minimizing visual clutter.
  • Monochromatic Iconography: Pristine tech-aesthetic utilizing universally scaled, single-color lucide-react iconography.

7. Performance Uncapping

  • Decoupled Engine Loop: The simulator logic is fully decoupled from the monitor's requestAnimationFrame refresh rate. Setting the Autoplay speed to < 0 engages an internal while loop that clones the physical board state, advances the engine thousands of ticks per second, and resolves the entire block of mutations back to the React UI in a single batched frame.

Vision: A Distributed Intelligence MMO

Slime-Go is evolving beyond a standalone AI testbed into a massively multiplayer research environment—an MMO for collective machine learning.

In a traditional game, the loop is play earn points upgrade. In Slime-Go, the Knowledge Economy loop is: participate train validate improve the global model. Human time invested in the ecosystem trains a shared global intelligence.

Players act in three interconnected roles:

  • Explorers (Data Generators): Play off-meta or chaotic games to produce novel topological states for the replay buffer.
  • Trainers (Model Tuners): Run intensive local simulations and tweak hyperparameter constants.
  • Validators (The Judges): Confirm predictions, judge ambiguous board states, and rank baseline Neural Candidate Models.

By combining background computation loops with active human oversight, Slime-Go aims to become a distributed intelligence civilization where spatial strategic intelligence is crowdsourced and endlessly refined.

Read the full architectural vision: A Distributed Intelligence MMO


Tech Stack

Slime-Go is proudly built with modern, high-performance tooling:

  • Frontend: React 19, TypeScript, Vite, Tailwind CSS v4, Framer Motion
  • Machine Learning Data: TensorFlow.js (@tensorflow/tfjs)
  • Backend/Signaling: Node.js, Express, Socket.io
  • Storage: LocalStorage (UI/Player Configs) & better-sqlite3 (Training/Tournament Logs)

Documentation Library

For complete mathematical modeling and architectural blueprints, see:


Running the Simulator Locally

Requirements: Node.js 20+

  1. Clone the repository and navigate to the root directory
  2. Install the necessary NPM dependencies:
npm install
  1. Start the Vite frontend and Node.js backend simultaneously:
npm run dev
  1. Open your browser and navigate to http://localhost:5173.

Note: For production builds, run npm run build to compile the static assets, and deploy the Node instance separately using npm start.