Skip to main content

Treant

High-performance, lock-free Monte Carlo Tree Search for Rust

Learn MCTS

Progressive tutorials from theory through AlphaZero-style search.

Start tutorials

Interactive Demos

Every concept backed by a live interactive demo you can manipulate.

Open playground

Production Code

All examples compiled and tested from the actual Rust source.

Browse docs

Capabilities

Lock-free parallel search
UCT + PUCT tree policies
MCTS-Solver (game-theoretic proving)
Score-Bounded MCTS
Open/closed-loop chance nodes
Batched neural network evaluation
Tree reuse across turns
Progressive widening

Minimal interface

Implement three methods and the library handles the rest.

pub trait GameState: Clone {
    type Move: Sync + Send + Clone;
    type Player: Sync;
    type MoveList: IntoIterator<Item = Self::Move>;

    /// The player whose turn it is.
    fn current_player(&self) -> Self::Player;

    /// Legal moves from this state. Empty means terminal.
    fn available_moves(&self) -> Self::MoveList;

    /// Apply a move, mutating the state in place.
    fn make_move(&mut self, mov: &Self::Move);
}