Package search.ab
Class Minimax_AB
java.lang.Object
search.AI
search.ab.Minimax_AB
An implementation of a Minimax Search for the game Jump Sturdy with Alpha-Beta Pruning,
Aspiration Windows, Transposition Tables and a Quiescence Search.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintgetBestMove(String fen) Determines the best move for a given board state represented by a FEN string.doubleiterativeDeepening(MoveGenerator gameState, double moveTimeLimit, Color ourColor) Performs an iterative deepening search to find the best move score within the given time limit.orchestrator(String fen, SearchConfig config) Orchestrates the AI on the given FEN position and search configuration.doublequiescenceSearch(MoveGenerator gameState, double alpha, double beta, Color currentColor, Color ourColor) Performs a quiescence search to evaluate positions more accurately by only exploring capture moves.Returns the configuration of the AI.doubletreeSearch(MoveGenerator gameState, double alpha, double beta, double endTime, int depth, Color currentColor, Color ourColor) Executes a recursive tree search with alpha-beta pruning to evaluate game positions and find the best possible move for the current player.
-
Field Details
-
maxDepth
public int maxDepth -
positionsHM
-
transpositionTable
-
bestConfig
-
-
Constructor Details
-
Minimax_AB
public Minimax_AB()
-
-
Method Details
-
orchestrator
Description copied from class:AIOrchestrates the AI on the given FEN position and search configuration.- Specified by:
orchestratorin classAI- Parameters:
fen- The current position in FEN notationconfig- The configuration object specifying the AI search parameters- Returns:
- The best move determined by the search algorithm
-
showConfig
Description copied from class:AIReturns the configuration of the AI.- Specified by:
showConfigin classAI- Returns:
- The configuration object
-
getBestMove
Determines the best move for a given board state represented by a FEN string. This method utilizes iterative deepening search with time management to evaluate possible moves and select the one with the highest score.- Parameters:
fen- The current position in FEN notation.- Returns:
- The best move determined based on the evaluation, represented as an integer.
-
quiescenceSearch
public double quiescenceSearch(MoveGenerator gameState, double alpha, double beta, Color currentColor, Color ourColor) Performs a quiescence search to evaluate positions more accurately by only exploring capture moves.- Parameters:
gameState- The current game state.alpha- The alpha value for alpha-beta pruning.beta- The beta value for alpha-beta pruning.currentColor- The color of the player whose turn it is.ourColor- The color of our player.- Returns:
- The best score for the current game state after exploring capture moves.
-
iterativeDeepening
Performs an iterative deepening search to find the best move score within the given time limit. This method incrementally deepens the search depth until the time runs out or the maximum allowed depth is reached. Alpha-Beta pruning is used to optimize the search.- Parameters:
gameState- The current state of the game represented by aMoveGeneratorobject.moveTimeLimit- The maximum time allowed for evaluating a move, in milliseconds.ourColor- The color of the player whose best move gets evaluated.- Returns:
- The best score obtained for the evaluated moves within the given time limit.
-
treeSearch
public double treeSearch(MoveGenerator gameState, double alpha, double beta, double endTime, int depth, Color currentColor, Color ourColor) Executes a recursive tree search with alpha-beta pruning to evaluate game positions and find the best possible move for the current player. This method can use, based on the configuration, transposition tables to store and get previously evaluated positions to optimize the search.- Parameters:
gameState- The current state of the game represented by aMoveGeneratorobject.alpha- The alpha value used in alpha-beta pruning.beta- The beta value used in alpha-beta pruning.endTime- The time when the search should stop, used for time management.depth- The depth left for the search tree.currentColor- The color of the player currently making a move.ourColor- The color of the player whose best move gets evaluated.- Returns:
- The best score obtained for the evaluated game position.
-