Skip to main content

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)

Metadata

Release files for mctspy 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mctspy 0.1.1
File Size Uploaded
mctspy-0.1.1.tar.gz 4.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mctspy 0.1.1
File Interpreter ABI Platform
mctspy-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 10.4 kB

Release files / mctspy-0.1.1.tar.gz

Download URL mctspy-0.1.1.tar.gz
Size 4.1 kB
Tags Source
SHA-256 checksum
How to use checksums
52d16193bdadeaca144bf28047367c13e8940a45d758a3a9c96c78d3b7226dfa
BLAKE2b-256 checksum
How to use checksums
b348cefb7f055e308c9ce63dbe079c23d6195be3040d42c3596ee515d66b02b6
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / mctspy-0.1.1-py3-none-any.whl

Download URL mctspy-0.1.1-py3-none-any.whl
Size 6.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fc7a87aa7654971ede89b63a58d2ed3171a498937d38bd7b53b79f4dea880354
BLAKE2b-256 checksum
How to use checksums
9325fb9812b54a0c7c6db86fa4ca89d1eb0db9f30d7242832bdb91dde950d818
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page