This package provides a implementation of Memory-Augmented Monte Carlo Tree Search, starting from the original MCTS and based on this paper: Memory-Augmented Monte Carlo Tree Search
Without pip: Download the zip/tar.gz file of the latest release, extract it, and run python setup.py install
. And please keep this directory un-deleted.
In order to run MCTS, you must implement a State
class which can fully describe the state of the world. It must also implement four methods:
getPossibleActions()
: Returns an iterable of all actions which can be taken from this statetakeAction(action)
: Returns the state which results from taking actionaction
isTerminal()
: Returns whether this state is a terminal stategetReward()
: Returns the reward for this state. Only needed for terminal states.
You must also choose a hashable representation for an action as used in getPossibleActions
and takeAction
. Typically this would be a class with a custom __hash__
method, but it could also simply be a tuple or a string.
Once these have been implemented, running MCTS is as simple as initializing your starting state, then running:
from mcts import mcts
mcts = mcts(timeLimit=1000)
bestAction = mcts.search(initialState=initialState)
See naughtsandcrosses.py for a simple example.
//TODO
Feel free to raise a new issue for any new feature or bug you've spotted. Pull requests are also welcomed if you're interested in directly improving the project.