|
Algorithm Development Kit 1.0 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectalgs.model.gametree.AlphaBetaEvaluation
public class AlphaBetaEvaluation
Initiate AlphaBeta Evaluation over the given game state and ply.
Base this implementation on the Negmax algorithm, since the pruning code is simpler to understand.
To properly enable debugging, we must invoke the counter methods of the IGameState being processed (incrementing when we expand and decrementing when we retract). The number of states explored can be found in the numStates class variable.
The toString method is provided to make it a bit easier to debug.
All lines commented with STAT can be eliminated and are only here to make it possible to generate statistics about the execution of the algorithm. Their overhead is minimal.
Note that a lookahead of ZERO will only return the evaluation of the board state and the returned move will be null.
Field Summary | |
---|---|
int |
numStates
statistical information to evaluate algorithms effectiveness. |
Constructor Summary | |
---|---|
AlphaBetaEvaluation(int ply)
Create an evaluator with the given state. |
Method Summary | |
---|---|
IGameMove |
bestMove(IGameState s,
IPlayer player,
IPlayer opponent)
Initiates the AlphaBeta computations by determining the maximum number of moves in advance to look. |
java.lang.String |
toString()
Expose board state as string (useful for debugging purposes). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public int numStates
Constructor Detail |
---|
public AlphaBetaEvaluation(int ply)
bestMove
is invoked.
ply
- Depth to search; must be greater than zero.Method Detail |
---|
public IGameMove bestMove(IGameState s, IPlayer player, IPlayer opponent)
The original game state is copied prior to being processed so no external effect occurs. This implementation is derived from NegMax and selects moves accordingly.
If no moves are available to player, then null is returned.
bestMove
in interface IEvaluation
s
- Game state being evaluated.player
- The player making the next move.opponent
- The player's opponent.public java.lang.String toString()
toString
in class java.lang.Object
|
Algorithm Development Kit 1.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |