GeneThello Home

net.sf.genethello.shared
Interface IBoard

All Known Implementing Classes:
Board

public interface IBoard

Board interface shared by several modules.

Author:
praz

Method Summary
 void addMovesUndoDepth(int i)
          Increments depth of undo of valid moves.
 void addSquaresUndoDepth(int i)
          Increments depth of undo of board simulation.
 int calcPatternValue(int turn)
          Calculates sum of all pattern values for certain color of disc.
 int countCorners(int turn)
          Calculates number of discs in corners for certain color.
 int countMobility(int turn)
          Counts mobility for current player.
 int countXsquares(int turn)
          Calculates number of discs in x-squares for certain color.
 int doPut(int idx, int turn)
          Puts new disc and flip opponent's discs if possible.
 void generate(int turn)
          Generates valid moves for current player.
 int[] getDiscs()
          Gets number of discs of both colors.
 int getDiscs(int turn)
          Gets number of discs.
 int getFlips()
          Gets the last number of flipped discs.
 int getMoves(int i)
          Gets index'th move from array of valid moves.
 int getSquares(int index)
          Gets value of a square in board.
 int getTotalDiscs()
          Gets total number of discs.
 void insertOrUpdatePatterns(int val)
          Insert or update patterns to database.
 void takePatterns()
          Stores all patterns in current board into several sets of pattern.
 int[] toIntArray()
          Integer array representation of board.
 void undoGenerate()
          Undoes the last Generate().
 void undoPut()
          Undoes the last doPut().
 

Method Detail

getDiscs

int getDiscs(int turn)
Gets number of discs.

Parameters:
turn - color of disc: Game.BLACK, Game.WHITE
Returns:
number of discs

getTotalDiscs

int getTotalDiscs()
Gets total number of discs.

Returns:
number of discs

getDiscs

int[] getDiscs()
Gets number of discs of both colors.

Returns:
number of discs

getFlips

int getFlips()
Gets the last number of flipped discs.

Returns:
number of flipped discs

countMobility

int countMobility(int turn)
Counts mobility for current player. Similar to generate() function except doesn't store found moves. Checks all empty squares each to 8 directions: Up, UpRight, Right, DownRight, Down, DownLeft, Left and UpLeft. Starting from current square it checks for opponent disc until own disc is found.

Parameters:
turn - Current player to count.

countCorners

int countCorners(int turn)
Calculates number of discs in corners for certain color.

Parameters:
turn - color of disc: Game.BLACK, Game.WHITE
Returns:
number of discs in corners

countXsquares

int countXsquares(int turn)
Calculates number of discs in x-squares for certain color.

Parameters:
turn - color of disc: Game.BLACK, Game.WHITE
Returns:
number of discs in x-squares

calcPatternValue

int calcPatternValue(int turn)
Calculates sum of all pattern values for certain color of disc.

Parameters:
turn - color of disc: Game.BLACK, Game.WHITE
Returns:
total pattern value

generate

void generate(int turn)
Generates valid moves for current player. Checks all empty squares each to 8 directions: Up, UpRight, Right, DownRight, Down, DownLeft, Left and UpLeft. Starting from current square it checks for opponent disc until own disc is found. Generated moves could be retrieved using getMoves().

Parameters:
turn - Current player to generate moves.

getMoves

int getMoves(int i)
Gets index'th move from array of valid moves.

Parameters:
i - index of move
Returns:
move

addMovesUndoDepth

void addMovesUndoDepth(int i)
Increments depth of undo of valid moves.

Parameters:
i - undo depth to increment

undoGenerate

void undoGenerate()
Undoes the last Generate().


doPut

int doPut(int idx,
          int turn)
Puts new disc and flip opponent's discs if possible. Flips in 8 directions: Up, UpRight, Right, DownRight, Down, DownLeft, Left and UpLeft. Starting from new disc it checks for opponent discs until own disc is found, then go back flipping those opponent discs. Doesn't put new disc if there is no opponent disc can be flipped.

Parameters:
idx - New disc's index (0- 63).
turn - New disc's turn (BLACK or WHITE).
Returns:
Number of flipped discs.

addSquaresUndoDepth

void addSquaresUndoDepth(int i)
Increments depth of undo of board simulation.

Parameters:
i - undo depth to increment

undoPut

void undoPut()
Undoes the last doPut().


toIntArray

int[] toIntArray()
Integer array representation of board.

Returns:
array of integer representing board

takePatterns

void takePatterns()
Stores all patterns in current board into several sets of pattern.


insertOrUpdatePatterns

void insertOrUpdatePatterns(int val)
Insert or update patterns to database.

Parameters:
val - value to increment the pattern

getSquares

int getSquares(int index)
Gets value of a square in board.

Parameters:
index - board index
Returns:
value

GeneThello Home

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