edu.lhup.ai
Class MinMaxAlphaBetaPlayer
java.lang.Object
|
+--edu.lhup.ai.MinMaxAlphaBetaPlayer
- All Implemented Interfaces:
- IPlayer
- public class MinMaxAlphaBetaPlayer
- extends Object
- implements IPlayer
A concrete player that plays any game using the minimax
algorithm with alpha-beta pruning and a cutoff. The code used by this
player is based on the psuedo code presented in Russell and Norvig's book,
"Artificial Intelligence: A Modern Approach". The
evaluator used by this player (see
setEvaluator(IEvaluator)) is important because it determines how the
end states are evaluated during the minimax search.
This software is for educational purposes only.
- Author:
- Mark Cohen
m_cutoff
protected int m_cutoff
m_evaluator
protected IEvaluator m_evaluator
MinMaxAlphaBetaPlayer
public MinMaxAlphaBetaPlayer()
setCutoff
public void setCutoff(int cutoff)
- Description copied from interface:
IPlayer
- Provides a mechanism for specifying the point at which a player's
abandons the search for the best move.
- Specified by:
setCutoff in interface IPlayer
- Parameters:
cutoff - an integer limiting the duration of a player's search for
the best move
setEvaluator
public void setEvaluator(IEvaluator evaluator)
- Description copied from interface:
IPlayer
- Provides a mechanism for specifying a player's evaluation strategy.
By implementing the
IEvaluator interface programmers can create
their own custom evaluators and request that a player use the evaluator
by calling this method.
- Specified by:
setEvaluator in interface IPlayer
- Parameters:
evaluator - the strategy used by this player in order to
evaluate the current game state.
getDescription
public String getDescription()
- Specified by:
getDescription in interface IPlayer
- Returns:
- a description of this player.
getShortDescription
public String getShortDescription()
- Specified by:
getShortDescription in interface IPlayer
- Returns:
- a short description of this player.
toString
public String toString()
- Overrides:
toString in class Object
takeTurn
public void takeTurn(IBoard board)
throws TurnException
- This player makes moves using the minimax algorithm with alpha-beta
pruning and a cutoff. The
evaluator used by this
player determines how end states will be evaluated during the minimax
search.
- Specified by:
takeTurn in interface IPlayer
- Parameters:
board - the IBoard object that this player will make a move
on.
- Throws:
TurnException - if the player attemts to push an invalid
move onto the games stack.
cutoff
protected boolean cutoff(IBoard board,
int iLevel)
getRating
protected int getRating(IBoard board,
int level,
int alpha,
int beta)
throws StateException
StateException