GeneThello Home

net.sf.genethello.applet
Class Brain

java.lang.Object
  extended by net.sf.genethello.applet.gametheory.GameTheory
      extended by net.sf.genethello.applet.Brain

public class Brain
extends GameTheory

A 'best move' searching class extending GameTheory class. It ables to search game tree up to certain depth using various algorithms such as NegaMax, AlphaBeta, NegaScout, MTD (Memory-enhanced Test Driver), and optionally with history table, transposition table and iterative deepening technique.

Author:
Bowo

Field Summary
protected  Chromosome chromosome
          Chromosome of the brain.
 
Fields inherited from class net.sf.genethello.applet.gametheory.GameTheory
bestmove, board, depth, historyTable, moveLength, step, timesUp, transpositionMaxIndex, transpositionTable, unquiet
 
Constructor Summary
Brain(IGame game, Chromosome chromosome, long timeQuota)
          Creates new instance of brain.
 
Method Summary
 void DoMove(int i)
          Does move using i'th valid moves.
protected  void DoMove(Move mv)
          Does move using valid move mv.
 int Eval()
          Evaluates value of move to be taken.
 void Generate()
          Generates array of valid moves.
 Chromosome getChromosome()
          Get the value of chromosome
 Move getMove(int i)
          Gets i'th move.
 Move getRandomMove()
          Gets random move from array of valid moves.
 void halveHistoryTable()
          Halves values of history table to avoid bad record in the past dominates the rating.
 void initBrain()
          Initializes brain.
 void initHistoryTable()
          Initializes history table.
 void initTranspositionTable()
          Initializes transposition table.
 int IterativeMTD()
          Calls _IterativeMTD() with time constraint.
protected  void PrintBoard()
          Print the board.
protected  void PrintMove(Move mv)
          Print move to standard output.
 void setBoard(Board b)
          Sets game board.
 void setChromosome(Chromosome chromosome)
          Set the value of chromosome
 void setTimeQuota(long time)
          Sets time quota of in milliseconds.
 void UndoGenerate()
          Undoes generation of valid moves.
 void UndoMove()
          Undoes move.
 
Methods inherited from class net.sf.genethello.applet.gametheory.GameTheory
_AlphaBetaFailSoftTransposition, AlphaBetaFailSoftTransposition, getBestmove, MTD, setDepth, setStep
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

chromosome

protected Chromosome chromosome
Chromosome of the brain.

Constructor Detail

Brain

public Brain(IGame game,
             Chromosome chromosome,
             long timeQuota)
Creates new instance of brain.

Parameters:
game - game in which brain is used
chromosome - chromosome to be used
timeQuota - time quota to think for a whole game (in ms)
Method Detail

initBrain

public final void initBrain()
Initializes brain.


Eval

public int Eval()
Evaluates value of move to be taken.

Specified by:
Eval in class GameTheory
Returns:
evaluation value

Generate

public void Generate()
Generates array of valid moves.

Specified by:
Generate in class GameTheory

UndoGenerate

public void UndoGenerate()
Undoes generation of valid moves.

Specified by:
UndoGenerate in class GameTheory

DoMove

public void DoMove(int i)
Does move using i'th valid moves.

Specified by:
DoMove in class GameTheory
Parameters:
i - index of valid moves

DoMove

protected void DoMove(Move mv)
Does move using valid move mv.

Specified by:
DoMove in class GameTheory
Parameters:
mv - move

UndoMove

public void UndoMove()
Undoes move.

Specified by:
UndoMove in class GameTheory

getMove

public Move getMove(int i)
Gets i'th move.

Specified by:
getMove in class GameTheory
Parameters:
i - index of valid moves
Returns:
i'th move

getRandomMove

public Move getRandomMove()
Gets random move from array of valid moves.

Returns:
random move

getChromosome

public Chromosome getChromosome()
Get the value of chromosome

Returns:
the value of chromosome

setChromosome

public void setChromosome(Chromosome chromosome)
Set the value of chromosome

Parameters:
chromosome - new value of chromosome

PrintBoard

protected void PrintBoard()
Print the board.

Specified by:
PrintBoard in class GameTheory

PrintMove

protected void PrintMove(Move mv)
Print move to standard output.

Specified by:
PrintMove in class GameTheory

initHistoryTable

public void initHistoryTable()
Initializes history table.


initTranspositionTable

public void initTranspositionTable()
Initializes transposition table.


setBoard

public void setBoard(Board b)
Sets game board.

Parameters:
b - board

halveHistoryTable

public void halveHistoryTable()
Halves values of history table to avoid bad record in the past dominates the rating.


IterativeMTD

public int IterativeMTD()
Calls _IterativeMTD() with time constraint.

Overrides:
IterativeMTD in class GameTheory
Returns:
best score

setTimeQuota

public void setTimeQuota(long time)
Sets time quota of in milliseconds.

Parameters:
time - time quota (in ms)

GeneThello Home

Get GeneThello: Genetic Othello at SourceForge.net. Fast, secure and Free Open Source software downloads