Class Minimax

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

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

    • Minimax

      public Minimax(GameState initialState)
      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

      public Minimax(GameState initialState, BotStrategyConfig config)
      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 from
      config - 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: 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