org.eclipse.palamedes.gdl.core.model.utils
Class Game

java.lang.Object
  extended by org.eclipse.palamedes.gdl.core.model.utils.Game
All Implemented Interfaces:
IGame
Direct Known Subclasses:
GameJocular, GameJP, GameProlog

public abstract class Game
extends java.lang.Object
implements IGame


Field Summary
protected  IGameNode initNode
           
protected  GDLKnowledgeBase kb
           
protected static java.util.Random random
          A random number generator.
protected  IReasoner reasoner
           
protected  java.lang.String[] roleNames
           
protected  java.lang.String sourceGDL
           
protected  IGameTree tree
          Game class protected stuff
 
Constructor Summary
Game()
           
 
Method Summary
 java.util.List<IMove[]> getCombinedMoves(IGameNode currentNode)
          Returns a list of all moves combined.
 int[] getGoalValues(IGameNode currentNode)
          Returns an array of the goal values of all players.
 IGameNode getInitialNode()
           
 GDLKnowledgeBase getKnowledgeBase()
          Returns the knowledge base that is used for this game.
 IMove[][] getLegalMoves(IGameNode currentNode)
          Returns an array of the legal moves of each player.
 int getMaxSteps()
          Returns the maximum number of steps if this information is known from the rules; otherwise -1;
 IGameNode getNextNode(IGameNode currentNode, IMove[] moves)
          Returns the child node of the parent that is connected through the specified moves.
 int getPerftValue(int depth, IGameNode startNode)
          Returns the perft(n) value starting from the given startNode.
 IMove[] getRandomMove(IGameNode currentNode)
          Returns a random combined move.
 IReasoner getReasoner()
          Returns the reasoner that is used for this game.
 int getRoleCount()
          Returns the number of roles respective the number of players.
 int getRoleIndex(java.lang.String role)
          Returns the index of the given role in the role name array.
 java.lang.String[] getRoleNames()
          Returns the string representation of the role names as string array.
 java.lang.String getSourceGDL()
          Returns the original GDL description for this game.
 IGameState getState(IGameNode currentNode)
          Returns the game state associated with currentNode.
 IStatistic getStatistic()
           
 IGameTree getTree()
          This method returns the game tree.
protected  void init(java.lang.String gdl, IReasoner initReasoner)
           
 boolean isTerminal(IGameNode currentNode)
          Returns true if the state of the node is a terminal state
 void regenerateNode(IGameNode node)
          This method regenerates the game states if the game node lost its state information for one reason or another.
static java.lang.String showGameNodePath(IGameNode node)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.palamedes.gdl.core.model.IGame
init
 

Field Detail

random

protected static final java.util.Random random
A random number generator.


tree

protected IGameTree tree
Game class protected stuff


reasoner

protected IReasoner reasoner

kb

protected GDLKnowledgeBase kb

sourceGDL

protected java.lang.String sourceGDL

roleNames

protected java.lang.String[] roleNames

initNode

protected IGameNode initNode
Constructor Detail

Game

public Game()
Method Detail

init

protected void init(java.lang.String gdl,
                    IReasoner initReasoner)

getTree

public IGameTree getTree()
This method returns the game tree.

Specified by:
getTree in interface IGame

getSourceGDL

public final java.lang.String getSourceGDL()
Description copied from interface: IGame
Returns the original GDL description for this game.

Specified by:
getSourceGDL in interface IGame

getRoleNames

public final java.lang.String[] getRoleNames()
Description copied from interface: IGame
Returns the string representation of the role names as string array.

Specified by:
getRoleNames in interface IGame

getInitialNode

public final IGameNode getInitialNode()

getRoleCount

public int getRoleCount()
Description copied from interface: IGame
Returns the number of roles respective the number of players.

Specified by:
getRoleCount in interface IGame

getRoleIndex

public int getRoleIndex(java.lang.String role)
Description copied from interface: IGame
Returns the index of the given role in the role name array.

Specified by:
getRoleIndex in interface IGame

getCombinedMoves

public java.util.List<IMove[]> getCombinedMoves(IGameNode currentNode)
                                         throws java.lang.InterruptedException
Description copied from interface: IGame
Returns a list of all moves combined.

Specified by:
getCombinedMoves in interface IGame
Throws:
java.lang.InterruptedException

getLegalMoves

public IMove[][] getLegalMoves(IGameNode currentNode)
                        throws java.lang.InterruptedException
Description copied from interface: IGame
Returns an array of the legal moves of each player.
e.g.: getLegalMoves(currentNode)[playerNumber] is an array of the legal moves of the specified player in the current state

Specified by:
getLegalMoves in interface IGame
Throws:
java.lang.InterruptedException

getNextNode

public IGameNode getNextNode(IGameNode currentNode,
                             IMove[] moves)
                      throws java.lang.InterruptedException
Description copied from interface: IGame
Returns the child node of the parent that is connected through the specified moves.

Specified by:
getNextNode in interface IGame
Throws:
java.lang.InterruptedException

getRandomMove

public IMove[] getRandomMove(IGameNode currentNode)
                      throws java.lang.InterruptedException
Description copied from interface: IGame
Returns a random combined move.

Specified by:
getRandomMove in interface IGame
Throws:
java.lang.InterruptedException

getGoalValues

public int[] getGoalValues(IGameNode currentNode)
                    throws java.lang.InterruptedException
Description copied from interface: IGame
Returns an array of the goal values of all players. A value of -1 is returned if there is no goal value for a player in this state. This may happen if the state is not terminal.

Specified by:
getGoalValues in interface IGame
Throws:
java.lang.InterruptedException

isTerminal

public boolean isTerminal(IGameNode currentNode)
                   throws java.lang.InterruptedException
Description copied from interface: IGame
Returns true if the state of the node is a terminal state

Specified by:
isTerminal in interface IGame
Throws:
java.lang.InterruptedException

getState

public IGameState getState(IGameNode currentNode)
                    throws java.lang.InterruptedException
Description copied from interface: IGame
Returns the game state associated with currentNode. Regenerates the node if necessary.

Specified by:
getState in interface IGame
Throws:
java.lang.InterruptedException
See Also:
IGame.regenerateNode(IGameNode node)

regenerateNode

public void regenerateNode(IGameNode node)
                    throws java.lang.InterruptedException
Description copied from interface: IGame
This method regenerates the game states if the game node lost its state information for one reason or another.

Specified by:
regenerateNode in interface IGame
Throws:
java.lang.InterruptedException

getStatistic

public IStatistic getStatistic()
Specified by:
getStatistic in interface IGame

getKnowledgeBase

public GDLKnowledgeBase getKnowledgeBase()
Description copied from interface: IGame
Returns the knowledge base that is used for this game.

Specified by:
getKnowledgeBase in interface IGame

getMaxSteps

public int getMaxSteps()
Description copied from interface: IGame
Returns the maximum number of steps if this information is known from the rules; otherwise -1;

Specified by:
getMaxSteps in interface IGame

showGameNodePath

public static java.lang.String showGameNodePath(IGameNode node)

getReasoner

public IReasoner getReasoner()
Description copied from interface: IGame
Returns the reasoner that is used for this game.

Specified by:
getReasoner in interface IGame

getPerftValue

public int getPerftValue(int depth,
                         IGameNode startNode)
                  throws java.lang.InterruptedException
Description copied from interface: IGame
Returns the perft(n) value starting from the given startNode. The perft value is defined as the number of game nodes reachable in exactly n steps.

Specified by:
getPerftValue in interface IGame
Throws:
java.lang.InterruptedException