Package a5.ai
Class Minimax<GameState,Move> 
java.lang.Object
a5.ai.Minimax<GameState,Move> 
Implementation of minimax search with alpha-beta pruning.
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic classAn exception signifying that the search algorithm ran out of time.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final intWhen to flush the table and start over
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidEffect: Turn on the use of a transposition table.findBestMove(GameState state, int searchTime) Returns: the best move from the given state that can be found by searching for up to a given amount of time.intReturns: the optimal minimax value of the current game state, within the range from min to max.voidsetAlphaBetaPruning(boolean value) Effect: Set whether alpha-beta pruning is used.voidsetShowSearchInfo(boolean value) Effect: Set whether search info is printed.
- 
Field Details- 
MAX_TRANSPOSITION_TABLE_SIZEpublic static final int MAX_TRANSPOSITION_TABLE_SIZEWhen to flush the table and start over- See Also:
 
 
- 
- 
Constructor Details- 
MinimaxCreate a new minimax AI search engine.- Parameters:
- model- The model of the game
 
 
- 
- 
Method Details- 
activateTranspositionTablepublic void activateTranspositionTable()Effect: Turn on the use of a transposition table.
- 
setAlphaBetaPruningpublic void setAlphaBetaPruning(boolean value) Effect: Set whether alpha-beta pruning is used. It is turned on by default.
- 
setShowSearchInfopublic void setShowSearchInfo(boolean value) Effect: Set whether search info is printed. It is turned on by default.
- 
findBestMoveReturns: the best move from the given state that can be found by searching for up to a given amount of time. ReturnsMaybe.none()if there is no legal move.- Parameters:
- state- the state to search from
- searchTime- the maximum time to search, in milliseconds
 
- 
searchReturns: the optimal minimax value of the current game state, within the range from min to max. The minimax value is computed with a specified search depth, with game states reached when depth is 0 evaluated heuristically. It may search deeper than the specified depth. Checks: min < max Requires: depth >= 0, -WIN <= min, max <= WIN. Throws OutOfTime if the search has run out of time.- Throws:
- Minimax.OutOfTime
 
 
-