|
GeneThello Home | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.genethello.applet.gametheory.GameTheory
public abstract class GameTheory
A framework for running algorithms of game theory (minimax type) to search best move for a two players zero-sum game. It contains several famous minimax type algorithms.
| Field Summary | |
|---|---|
protected Move |
bestmove
Best move found so far. |
protected Board |
board
Board used in the game. |
protected int |
depth
Thinking depth. |
protected int[] |
historyTable
Array of integer to hold history table. To use this feature, the following should be done: Declares historyTable to be size of 2 * possible valid moves. |
protected int |
moveLength
Number of valid moves. |
protected int |
step
Current step of game. |
protected boolean |
timesUp
Terminates searching process if time's up is true. |
protected long |
transpositionMaxIndex
Maximum index of transposition table, should be (power of two) - 1, so that the size is power of two. |
protected TranspositionTable[] |
transpositionTable
Array of TranspositionTable to hold transposition table. To use this feature, the following should be done: Declares transpositionMaxIndex to be (power of two) - 1 somewhere in program initialization. e.g. |
protected boolean |
unquiet
Does quiescence search if true. |
| Constructor Summary | |
|---|---|
GameTheory()
Creates a new instance of GameTheory |
|
| Method Summary | |
|---|---|
protected int |
_AlphaBetaFailSoftTransposition(int d,
int alpha,
int beta)
Recursive portion of AlphaBetaFailSoftTransposition algorithm. |
int |
AlphaBetaFailSoftTransposition(int d,
int alpha,
int beta)
Searches game tree using AlphaBetaFailSoft algorithm and transposition table. |
abstract void |
DoMove(int i)
Does i-th move from valid moves. |
protected abstract void |
DoMove(Move mv)
Does move mv. |
abstract int |
Eval()
Evaluates leaf position from current player's standpoint. |
abstract void |
Generate()
Generates valid moves of next board position. |
Move |
getBestmove()
Gets best move. |
abstract Move |
getMove(int i)
Gets i-th move from valid moves. |
int |
IterativeMTD()
Searches game tree using Memory-enhanced Test Driver algorithm and transposition table with iterative deepening. |
int |
MTD(int d,
int f)
/** Searches game tree using Memory-enhanced Test Driver algorithm and transposition table. |
protected abstract void |
PrintBoard()
Prints board position to standard output. |
protected abstract void |
PrintMove(Move mv)
Prints move to standard output. |
void |
setDepth(int depth)
Sets the depth. |
void |
setStep(int step)
Sets current step of game simulation. |
abstract void |
UndoGenerate()
Retracts generated valid moves and puts board back to previous position. |
abstract void |
UndoMove()
Undo last move. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected int[] historyTable
historyTable= new int[2 * Constants.SQNUM];
protected TranspositionTable[] transpositionTable
transpositionMaxIndex = (long) (Math.pow(2, 20) - 1);
transpositionTable = new TranspositionTable[(int) transpositionMaxIndex + 1];
private long zobristKey = 0;
private long[][] zsquares = new long[Constants.SQNUM][2];
Random rnd = new Random();
for (int i = 0; i < Constants.SQNUM; i++) {
for (int j = 0; j < 2; j++) {
zsquares[i][j] = rnd.nextLong();
}
}
zobrist values for each color having turn to moveprivate long[] zturn = new long[2];
zturn[0] = rnd.nextLong(); zturn[1] = rnd.nextLong(); zobristKey = 0;
zobristKey ^= zsquares[index][turn];
zobristKey ^= zturn[turn];
return zobristKey;
protected long transpositionMaxIndex
protected int depth
protected Board board
protected Move bestmove
protected int moveLength
protected int step
protected boolean unquiet
protected boolean timesUp
| Constructor Detail |
|---|
public GameTheory()
| Method Detail |
|---|
public int AlphaBetaFailSoftTransposition(int d,
int alpha,
int beta)
(* Initial call *) AlphaBetaFailSoftTransposition(depth, -infinity, +infinity)
d - depthalpha - lower bound of expected value of the treebeta - upper bound of expected value of the tree
protected int _AlphaBetaFailSoftTransposition(int d,
int alpha,
int beta)
d - depthalpha - lower bound of expected value of the treebeta - upper bound of expected value of the tree
public int MTD(int d,
int f)
(* Initial call *) MTD(depth, 0)
d - depthf - first guess of expected value of the tree
public int IterativeMTD()
(* Initial call *) IterativeMTD()
public abstract int Eval()
public abstract void Generate()
public abstract void UndoGenerate()
public abstract void DoMove(int i)
i - move indexprotected abstract void DoMove(Move mv)
mv - movepublic abstract void UndoMove()
public abstract Move getMove(int i)
i - move index
public void setDepth(int depth)
depth - depthpublic Move getBestmove()
public void setStep(int step)
step - current stepprotected abstract void PrintBoard()
protected abstract void PrintMove(Move mv)
|
GeneThello Home | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||