Class MonteCarloTreeSearch
java.lang.Object
org.xxdc.oss.example.bot.MonteCarloTreeSearch
- All Implemented Interfaces:
BotStrategy
Implements the Monte Carlo Tree Search (MCTS) algorithm for a game bot strategy. The MCTS
algorithm is used to select the best move for the current game state by simulating random game
play and backpropagating the results to update the search tree. The algorithm can be configured
with a maximum time limit and maximum number of iterations.
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionMonteCarloTreeSearch(GameState state) Constructs a new instance of theMonteCarloTreeSearchclass with the given initial game state and a default configuration (max time limit of 1 second).MonteCarloTreeSearch(GameState state, BotStrategyConfig config) Constructs a new instance of theMonteCarloTreeSearchclass with the given initial game state and configuration. -
Method Summary
Modifier and TypeMethodDescriptionintbestMove()Returns the best move for the current game state.
-
Constructor Details
-
MonteCarloTreeSearch
Constructs a new instance of theMonteCarloTreeSearchclass with the given initial game state and a default configuration (max time limit of 1 second).- Parameters:
state- the initial game state to use for the Monte Carlo tree search
-
MonteCarloTreeSearch
Constructs a new instance of theMonteCarloTreeSearchclass with the given initial game state and configuration.- Parameters:
state- the initial game state to use for the Monte Carlo tree searchconfig- the configuration settings for the Monte Carlo tree search
-
-
Method Details
-
bestMove
public int bestMove()Description copied from interface:BotStrategyReturns the best move for the current game state.- Specified by:
bestMovein interfaceBotStrategy- Returns:
- the index of the best move to make
-