API Reference

Core Services

Base Models

class mcts_gen.models.game_state.GameStateBase

Abstract base class for any game environment that can be used with McpMcts.

abstractmethod getCurrentPlayer() int

Return +1 if it’s player one’s turn, -1 if it’s player two’s turn.

abstractmethod getPossibleActions() List[Any]

Return a list of all possible actions from this state. The actions MUST be serializable and preferably human-readable strings (e.g., USI for shogi) to allow AI agents to process them.

abstractmethod getReward() float

Return the reward for the current player if the game is terminal. Convention: +1 (win), -1 (loss), 0 (draw).

get_state_summary() Any

Returns a summary of the current state. This can be overridden by subclasses to provide richer, game-specific information.

abstractmethod isTerminal() bool

Return True if this state is terminal (game over).

abstractmethod takeAction(action: Any) GameStateBase

Return the new GameState after applying the given action.

Game Modules

This framework can be extended with different games. Below are the provided examples.

A dummy game implementation (Tic-Tac-Toe) for testing and demonstration.

class mcts_gen.games.dummy_game.TicTacToeDummy(board: List[int] | None = None, player: int = 1)

A simplified Tic-Tac-Toe game state for testing the MCTS engine.

getCurrentPlayer() int

Returns the current player.

getPossibleActions() List[int]

Returns a list of possible moves (empty squares).

getReward() float

Returns the reward for the game outcome.

isTerminal() bool

Checks if the game is over (no more moves).

takeAction(action: int) TicTacToeDummy

Applies a move and returns the new game state.