Class AlphaBeta

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

public final class AlphaBeta extends Object implements BotStrategy
Implements the Alpha-Beta pruning algorithm for a two-player game. The algorithm evaluates game states and selects the best move for the current player. It uses a depth-limited search to explore the game tree, and prunes branches that are guaranteed to be inferior. The algorithm aims to maximize the score for the current player (the "maximizer") and minimize the score for the opponent.
  • Constructor Details

    • AlphaBeta

      public AlphaBeta(GameState initialState)
      Constructs an instance of the AlphaBeta bot strategy with the given initial game state and default configuration.
      Parameters:
      initialState - the initial game state for the bot to analyze
    • AlphaBeta

      public AlphaBeta(GameState initialState, BotStrategyConfig config)
      Constructs an instance of the AlphaBeta bot strategy with the given initial game state and configuration.
      Parameters:
      initialState - the initial game state for the bot to analyze
      config - the configuration settings for the bot strategy
      Throws:
      IllegalArgumentException - if the initial game state does not have exactly two players
  • 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