A very simple C++ MCTS (Monte Carlo Tree Search) implementation with examples for openFrameworks
C++ QML Makefile
Permalink
Failed to load latest commit information.
example_circle simplified State interface (no need for clone from, just copy or assi… Feb 6, 2016
example_oxo simplified State interface (no need for clone from, just copy or assi… Feb 6, 2016
src optionally return all explored states Feb 6, 2016
.gitignore
readme.md update to OF09 + VS2015 Jan 18, 2016

readme.md

A very simple C++11 Templated MCTS (Monte Carlo Tree Search) implementation with examples for openFrameworks.

MCTS Code Based on the Java (Simon Lucas - University of Essex) and Python (Peter Cowling, Ed Powley, Daniel Whitehouse - University of York) impelementations at http://mcts.ai/code/index.html

The code is not tailored for any specific use case. It's very generic (but perhaps not generic enough?) It's probably not very optimized, my priority was on readability and flexibility (I wrote it to understand MCTS). It supports variable number of agents, and variable number of actions per step, and is templated. See examples for how to design your 'State' and 'Action' classes.

Usage

    State state;            // contains the current state, it must comply with the State interface
    Action action;          // contains an action that can be applied to a State, and bring it to a new State
    UCT<State, Action> uct; // Templated class. Builds a partial decision tree and searches it with UCT MCTS

    // OPTIONAL init uct params
    uct.uct_k = sqrt(2);
    uct.max_millis = 0;
    uct.max_iterations = 100;
    uct.simulation_depth = 5;

    loop {
        // run uct mcts on current state and get best action
        action = uct.run(state);

        // apply the action to the current state
        state.apply_action(action);
    }

Dependencies:

Library itself

None (C++11)

Examples

openFrameworks 0.9.0

should work on any platform, but project files currently exist only for Windows / VS2015