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

java.lang.Object
  extended by org.eclipse.palamedes.gdl.core.model.utils.GameNode
All Implemented Interfaces:
IGameNode

public final class GameNode
extends java.lang.Object
implements IGameNode


Constructor Summary
GameNode()
           
GameNode(IGameNode parent, IGameState state, IMove[] moves)
           
 
Method Summary
 int getDepth()
          Returns the depth of the node in the game tree where 0 is the initial state.
static java.util.List<IFluent>[] getDiff(IGameState nodeA, IGameState nodeB)
           
static int[] getDiffCount(IGameState nodeA, IGameState nodeB)
           
 IMove[] getMoves()
          Returns the moves that have lead to this game node.
 IGameNode getParent()
          Returns the parent node or null if none exist.
 IGameState getState()
          Returns the associated game state if it is still in memory.
 boolean isPreserved()
          Returns if this game nodes content should be preserved even in the case of compacting the game tree.
 boolean isTerminal()
          Returns whether this node is a terminal node or not.
 void setPreserve(boolean preserve)
          Sets whether this game nodes content should be preserved even in the case of compacting the game tree.
 void setState(IGameState state)
          Sets the associated game state
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GameNode

public GameNode()

GameNode

public GameNode(IGameNode parent,
                IGameState state,
                IMove[] moves)
Method Detail

getParent

public IGameNode getParent()
Description copied from interface: IGameNode
Returns the parent node or null if none exist.

Specified by:
getParent in interface IGameNode

getDepth

public int getDepth()
Description copied from interface: IGameNode
Returns the depth of the node in the game tree where 0 is the initial state.

Specified by:
getDepth in interface IGameNode

getState

public IGameState getState()
Description copied from interface: IGameNode
Returns the associated game state if it is still in memory. getState() may return null after compacting the game tree (which happens automatically) unless the nodes isPreserved() method returns true. IGame.regenerateNode(node) will restore the state in this case.

Specified by:
getState in interface IGameNode
See Also:
IGameNode.isPreserved(), IGameNode.setPreserve(boolean preserve), IGame.regenerateNode(IGameNode node)

setState

public void setState(IGameState state)
Description copied from interface: IGameNode
Sets the associated game state

Specified by:
setState in interface IGameNode

getMoves

public IMove[] getMoves()
Description copied from interface: IGameNode
Returns the moves that have lead to this game node.

Specified by:
getMoves in interface IGameNode

isPreserved

public boolean isPreserved()
Description copied from interface: IGameNode
Returns if this game nodes content should be preserved even in the case of compacting the game tree.

Specified by:
isPreserved in interface IGameNode

setPreserve

public void setPreserve(boolean preserve)
Description copied from interface: IGameNode
Sets whether this game nodes content should be preserved even in the case of compacting the game tree.

Specified by:
setPreserve in interface IGameNode

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getDiffCount

public static int[] getDiffCount(IGameState nodeA,
                                 IGameState nodeB)

getDiff

public static java.util.List<IFluent>[] getDiff(IGameState nodeA,
                                                IGameState nodeB)

isTerminal

public boolean isTerminal()
Description copied from interface: IGameNode
Returns whether this node is a terminal node or not.

Specified by:
isTerminal in interface IGameNode