Class Minimax
java.lang.Object
org.xxdc.oss.example.bot.Minimax
- All Implemented Interfaces:
BotStrategy
Implements a Minimax algorithm-based bot strategy for a game. The Minimax algorithm is a
decision-making algorithm used in game theory and artificial intelligence to find the optimal
move for a player, assuming the opponent plays optimally. This implementation of the Minimax
algorithm is used to determine the best move for the current player in the game.
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new Minimax instance with the given initial game state and default bot strategy configuration.Minimax(GameState initialState, BotStrategyConfig config) Constructs a new Minimax instance with the given initial game state and bot strategy configuration. -
Method Summary
Modifier and TypeMethodDescriptionintbestMove()Returns the best move for the current game state.
-
Constructor Details
-
Minimax
Constructs a new Minimax instance with the given initial game state and default bot strategy configuration.- Parameters:
initialState- the initial game state to start the Minimax algorithm from
-
Minimax
Constructs a new Minimax instance with the given initial game state and bot strategy configuration.- Parameters:
initialState- the initial game state to start the Minimax algorithm fromconfig- the bot strategy configuration to use for this Minimax instance- 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
-