Class AlphaBeta
java.lang.Object
org.xxdc.oss.example.bot.AlphaBeta
- All Implemented Interfaces:
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.
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs an instance of the AlphaBeta bot strategy with the given initial game state and default configuration.AlphaBeta(GameState initialState, BotStrategyConfig config) Constructs an instance of the AlphaBeta bot strategy with the given initial game state and configuration. -
Method Summary
Modifier and TypeMethodDescriptionintbestMove()Returns the best move for the current game state.
-
Constructor Details
-
AlphaBeta
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
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 analyzeconfig- 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:BotStrategyReturns the best move for the current game state.- Specified by:
bestMovein interfaceBotStrategy- Returns:
- the index of the best move to make
-