Class MonteCarloTreeSearch

java.lang.Object
org.xxdc.oss.example.bot.MonteCarloTreeSearch
All Implemented Interfaces:
BotStrategy

public final class MonteCarloTreeSearch extends Object implements 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.
  • Constructor Details

    • MonteCarloTreeSearch

      public MonteCarloTreeSearch(GameState state)
      Constructs a new instance of the MonteCarloTreeSearch class 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

      public MonteCarloTreeSearch(GameState state, BotStrategyConfig config)
      Constructs a new instance of the MonteCarloTreeSearch class with the given initial game state and configuration.
      Parameters:
      state - the initial game state to use for the Monte Carlo tree search
      config - the configuration settings for the Monte Carlo tree search
  • Method Details

    • bestMove

      public int bestMove()
      Description copied from interface: BotStrategy
      Returns the best move for the current game state.
      Specified by:
      bestMove in interface BotStrategy
      Returns:
      the index of the best move to make