|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Board
A game board interface that can form
the basis of any deterministic 2 player strategy game middle tier.
Classes that implement Board
hold information
about a specific game position. Once a class implements Board
then the work of developing the game middle tier is complete because
class Game
supplies all logic required to calculate
optimal moves.
Game
Method Summary | |
---|---|
Board |
copy()
Return a copy (ignoring move iterator state). |
int |
getActiveSide()
Get an index identifying the active side (whose turn it is). |
int |
getAlteredLevelOfPlay(int requestedLevel)
Return the number of turns the Game engine should look ahead. |
Move |
getFirstMove()
Reset the board's move iterator and return the first move. |
int |
getGoodEnoughScore(int plannedScore,
int levelOfPlay)
Return a score which is good enough that a player need look no farther to see how much better it gets. |
Move |
getLastMoveExecuted()
Return the last move that was executed. |
Board |
getNewBoard()
Return a new board ready for a new game. |
Move |
getNextMove()
Return the next move based on the board's move iterator. |
int |
getProgress()
Return a measure of progress towards the game conclusion. |
int |
getRepetitionPenalty(int nRepeats)
Get a score penalty for repeating a position so many times. |
int |
getScore()
Express the position's merits as a scalar relative score. |
Move |
getUndefinedMove()
Return a new move which has not yet been defined. |
void |
go(Move move)
Execute the given move. |
boolean |
isSame(Board board)
Compare board states (ignoring move iterator state). |
boolean |
isWon(int score)
Return true if the given score means that either side won. |
void |
setFrom(Board board)
Set the board state to that of board ,
(ignoring move iterator state). |
void |
setFromJSON(org.json.simple.JSONObject jsonBoard)
Set this board based on the parameter. |
org.json.simple.JSONObject |
toJSONObject()
|
Method Detail |
---|
org.json.simple.JSONObject toJSONObject()
void setFromJSON(org.json.simple.JSONObject jsonBoard)
Board getNewBoard()
Move getUndefinedMove()
Board copy()
void setFrom(Board board)
board
,
(ignoring move iterator state).
board
- the original board to copy.boolean isSame(Board board)
int getActiveSide()
int getScore()
Board
's play by finding optimal
weights (as with genetic algorithms) for getScore's criteria.
Humans surpass computers in performance of this method.
int getGoodEnoughScore(int plannedScore, int levelOfPlay)
Game
engine optimizes by pruning move search tree
branches using this score. The returned score should be just above
what is probable based on plannedScore
for optimal performance. Towards the end game
the returned score should be far higher than what is probable.
levelOfPlay
is optionally
used to set expectations for what is good enough.
plannedScore
- expectations based on a previous search.levelOfPlay
- level of play requested by the Game engine.
plannedScore
.int getRepetitionPenalty(int nRepeats)
nRepeats
times. This encourages
variety of play and draw avoidance at the expense of good
judgment.
nRepeats
- the number of times this position has
already occurred during this game.
int getAlteredLevelOfPlay(int requestedLevel)
Game
engine should look ahead.
Each turn has one move and possibly several "go again" moves,
so the number of moves looked ahead may exceed the level of play.
Even though the game engine may request a certain level
of play, getAlteredLevelOfPlay()
may arbitrarily override
it at various stages of the game for performance reasons.
requestedLevel
- the level of play requested.
Move getFirstMove()
Move getNextMove()
Move getLastMoveExecuted()
void go(Move move)
getFirstMove()
,
getNextMove()
boolean isWon(int score)
int getProgress()
getGoodEnoughScore
may subvert this method by pruning (and thus ignoring)
moves which conclude the game sooner.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |