MCTS
This package provides a simple way of using Monte Carlo Tree Search in any perfect information domain.
Installation
With pip: pip install mcts
Without pip: Download the zip/tar.gz file of the latest release, extract it, and run python setup.py install
Quick Usage
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 actionactionisTerminal(): 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.
Slow Usage
//TODO
Collaborating
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.
Release files for mcts 1.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mcts-1.0.4.tar.gz | 3.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mcts-1.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.4 kB
Release files / mcts-1.0.4.tar.gz
| Download URL | mcts-1.0.4.tar.gz |
|---|---|
| Size | 3.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
01923d3d33cd6cc6e31b1f9d5f10943adc7ae3c399d0d6fedae3dae0541d5ec0
|
|
BLAKE2b-256 checksum How to use checksums |
24055d9433441d3d7826ded877bbb99b33f1557fef867c4247a65a1b03ba44fd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.4.3
|
Release files / mcts-1.0.4-py3-none-any.whl
| Download URL | mcts-1.0.4-py3-none-any.whl |
|---|---|
| Size | 4.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d140587f724ba04094116a9f9245a35f8d96e4cb2efbd5dfc20d1218d24dfad3
|
|
BLAKE2b-256 checksum How to use checksums |
8a2ad278c768df13364dbeb20a2baab209b72cf30cdc157a55ffc04f126c8b0a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.4.3
|