Skip to main content

Monte Carlo Tree Search for multiple teams

Project description

MultiMCTS

MultiMCTS is a Python package that implements the Monte Carlo Tree Search algorithm for board games played by any number of players. With MultiMCTS, you can create AI for any board game merely by knowing the rules -- no strategy needed!

Features

  • Efficient (largely C-compiled) MCTS implementation
  • Support for any number of players/teams
  • Easily create AI for any board game

Installation

pip install multimcts

Game Implementation

For your game, you will need to:

  • Represent the game state in code
  • Identify all legal moves
  • Determine if the game is over and who won

You do NOT need to:

  • Have domain knowledge
  • Understand any strategy
  • Evaluate the favorability of a game state

Usage

To use MultiMCTS, you must define your game by subclassing GameState and implementing the required methods (see tictactoe.py for an example):

  • get_current_team
  • get_legal_moves
  • make_move
  • is_terminal
  • get_reward
from multimcts import MCTS, GameState

class MyGameState(GameState):
    # your implementation here...

mcts = MCTS(max_time=1)         # Create an MCTS agent. This one will spend 1 second searching for the best move.
state = MyGameState()           # Set up a new game.
while not state.is_terminal():  # Continue until the game is over.
    print(state)                # Print the current game state (implementing GameState.__repr__ might be helpful).
    state = mcts.search(state)  # Use the best move found so far.
print(state)                    # Print the final game state.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

multimcts-0.1.5.tar.gz (80.2 kB view details)

Uploaded Source

File details

Details for the file multimcts-0.1.5.tar.gz.

File metadata

  • Download URL: multimcts-0.1.5.tar.gz
  • Upload date:
  • Size: 80.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.6

File hashes

Hashes for multimcts-0.1.5.tar.gz
Algorithm Hash digest
SHA256 c1b02c6d7f17b6292ba55800aa245cd4a7cc4f59ce9bceedb1b6bef800ef5eef
MD5 6cd6fe9a7ef6e9dc18ce033520cc157a
BLAKE2b-256 9939c0272f3ee4cb5617d16b1c942f79914b5e273d5308a6917711c1d4f0823d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page