knockabout.gamemodel
Class GameState

java.lang.Object
  extended byknockabout.gamemodel.GameState

public class GameState
extends java.lang.Object

The state of a knockabout game


Constructor Summary
GameState()
           
 
Method Summary
 void applyCompiledMove(CompiledMove move)
          Apply a compiled move to the state Note: there is no check if this compiled move is valid for this state, it will throw a NullPointerException if it is not the case TODO: throw a more intelligent RunTimeException...
 CompiledMove applyMove(Move move)
          Applies the supplied game move by player color 'playercolor' on the game board.
 GameState deepClone()
          Perform a deep clone, including a fresh copy of all the enclosing objects
 Board getBoardPosition()
           
 Die getDieToRoll()
          If the previous move applied involved the roll of a dice, the dice to roll is left unchanged, BUT this field is updated so it is the responsability of the player to reroll it/update it
 int getMaxColor()
          See class Player
 int getMinColor()
           
 float getUtility()
          Evaluate the utility of this knockabout state, 1 if the player of color maxColor wins, -1 if maxColor player loses, 0 otherwise
 java.util.List possibleMoves(int playerColor)
          Enumerate all valid move for a given player
 void setBoardPosition(Board board)
           
 void setDieToRoll(Die die)
           
 void setMaxColor(int i)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GameState

public GameState()
Method Detail

possibleMoves

public java.util.List possibleMoves(int playerColor)
Enumerate all valid move for a given player

Parameters:
playerColor - The color of the given player (see class Player)
Returns:
a list of valid Move objects

getUtility

public float getUtility()
Evaluate the utility of this knockabout state, 1 if the player of color maxColor wins, -1 if maxColor player loses, 0 otherwise

Returns:

applyCompiledMove

public void applyCompiledMove(CompiledMove move)
Apply a compiled move to the state Note: there is no check if this compiled move is valid for this state, it will throw a NullPointerException if it is not the case TODO: throw a more intelligent RunTimeException...

Parameters:
move - The compiled move

applyMove

public CompiledMove applyMove(Move move)
Applies the supplied game move by player color 'playercolor' on the game board. Also compute the corresponding CompiledMove Again, no guarantees that an intelligent exception will be thrown TODO: fix me

Parameters:
move - The Move to execute on this state
Returns:
The compiledMove computed

getBoardPosition

public Board getBoardPosition()
Returns:
The enclosing board position

getDieToRoll

public Die getDieToRoll()
If the previous move applied involved the roll of a dice, the dice to roll is left unchanged, BUT this field is updated so it is the responsability of the player to reroll it/update it

Returns:
The die to roll if any, else null

getMaxColor

public int getMaxColor()
See class Player

Returns:
The color code for the max player

setBoardPosition

public void setBoardPosition(Board board)
Parameters:
board -

setDieToRoll

public void setDieToRoll(Die die)
Parameters:
die -

setMaxColor

public void setMaxColor(int i)
Parameters:
i -

getMinColor

public int getMinColor()
Returns:

deepClone

public GameState deepClone()
Perform a deep clone, including a fresh copy of all the enclosing objects

Returns:
The fresh cloned object

toString

public java.lang.String toString()