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
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() # Create an MCTS agent.
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, max_time=1) # Play the best move found.
print(state) # Print the final game state.
License
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
multimcts-0.2.2.tar.gz
(66.0 kB
view details)
File details
Details for the file multimcts-0.2.2.tar.gz
.
File metadata
- Download URL: multimcts-0.2.2.tar.gz
- Upload date:
- Size: 66.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5675e8edca395210486a03ca995605e2dac988e2ddaea81ecad3f1b8c34a5f4a |
|
MD5 | de8d65d2874bc55864aca9995c60d768 |
|
BLAKE2b-256 | 8b96bcb18c1f0525dea62ae6e288cf684fa71998ba6b0a6be5a942c567d2a2d7 |