Python implementation of monte carlo tree search for 2 players zero-sum game
Project description
mctspy : python implementation of Monte Carlo Tree Search algorithm
Basic python implementation of Monte Carlo Tree Search (MCTS) intended to run on small game trees.
Installation
pip3 install mctspy
Running tic-tac-toe example
to run tic-tac-toe example:
import numpy as np
from mctspy.tree.nodes import TwoPlayersGameMonteCarloTreeSearchNode
from mctspy.tree.search import MonteCarloTreeSearch
from mctspy.games.examples.tictactoe import TicTacToeGameState
state = np.zeros((3,3))
initial_board_state = TicTacToeGameState(state = state, next_to_move=1)
root = TwoPlayersGameMonteCarloTreeSearchNode(state = initial_board_state)
mcts = MonteCarloTreeSearch(root)
best_node = mcts.best_action(10000)
Running MCTS for your own 2 players zero-sum game
If you want to apply MCTS for your own game, its state implementation should derive from
mmctspy.games.common.TwoPlayersGameState
(lookup mctspy.games.examples.tictactoe.TicTacToeGameState
for inspiration)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mctspy-0.1.1.tar.gz
(4.1 kB
view details)
Built Distribution
File details
Details for the file mctspy-0.1.1.tar.gz
.
File metadata
- Download URL: mctspy-0.1.1.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.1.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 52d16193bdadeaca144bf28047367c13e8940a45d758a3a9c96c78d3b7226dfa |
|
MD5 | 42d49ca857cf4dd39c5aa70cc2b018aa |
|
BLAKE2b-256 | b348cefb7f055e308c9ce63dbe079c23d6195be3040d42c3596ee515d66b02b6 |
File details
Details for the file mctspy-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: mctspy-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.1.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc7a87aa7654971ede89b63a58d2ed3171a498937d38bd7b53b79f4dea880354 |
|
MD5 | eeed96f969d129c50d354253d8242f3c |
|
BLAKE2b-256 | 9325fb9812b54a0c7c6db86fa4ca89d1eb0db9f30d7242832bdb91dde950d818 |