Class GameNode

java.lang.Object
  |
  +--GameNode
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
MancalaNode

public abstract class GameNode
extends java.lang.Object
implements java.lang.Cloneable

A general representation for a discrete game node. Creation date: (10/6/00 12:15:19 PM)


Field Summary
 GameNode parent
          variable parent - parent of this game node
protected  int player
          first player MAXimizer by default
 int prevMove
          previous move applied to reach this node.
 
Constructor Summary
GameNode()
           
 
Method Summary
 GameNode childClone()
          childClone - returns a clone of this node that has been made a child of this node and has a depth one greater than this.
 java.lang.Object clone()
          clone - see Main (pp.
 java.util.Vector expand()
          expand - return a Vector of all possible next game states
abstract  boolean gameOver()
          Return result of terminal state test.
abstract  int[] getLegalMoves()
          Return an array of integers encoding legal moves for current state.
 int getPlayer()
          getPlayer - return the current player (GameNode.MAX or GameNode.MIN).
abstract  void initialState()
          Set game to initial state.
abstract  void makeMove(int move)
          Assuming move is a legal move (see legalMoves()), make the appropriate change to the game state and update the player.
abstract  double utility()
          Return the estimated utility of the current game position, unless game is over.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

player

protected int player
first player MAXimizer by default

prevMove

public int prevMove
previous move applied to reach this node.

parent

public GameNode parent
variable parent - parent of this game node
Constructor Detail

GameNode

public GameNode()
Method Detail

getPlayer

public int getPlayer()
getPlayer - return the current player (GameNode.MAX or GameNode.MIN).
Returns:
an int value GameNode.MAX or GameNode.MIN

expand

public java.util.Vector expand()
expand - return a Vector of all possible next game states
Returns:
a Vector of all possible next game states

childClone

public GameNode childClone()
childClone - returns a clone of this node that has been made a child of this node and has a depth one greater than this.
Returns:
a SearchNode value

clone

public java.lang.Object clone()
clone - see Main (pp. 76-80)
Overrides:
clone in class java.lang.Object
Returns:
an Object value

gameOver

public abstract boolean gameOver()
Return result of terminal state test. Creation date: (10/6/00 12:33:21 PM)
Returns:
boolean

initialState

public abstract void initialState()
Set game to initial state. Creation date: (10/6/00 12:22:05 PM)

getLegalMoves

public abstract int[] getLegalMoves()
Return an array of integers encoding legal moves for current state. Creation date: (10/6/00 12:24:32 PM)
Returns:
int[]

makeMove

public abstract void makeMove(int move)
Assuming move is a legal move (see legalMoves()), make the appropriate change to the game state and update the player. Creation date: (10/6/00 12:34:41 PM)
Parameters:
move - int

utility

public abstract double utility()
Return the estimated utility of the current game position, unless game is over. If game is over, return actual utility. Player MAX maximizes this; player MIN minimizes this. Creation date: (10/6/00 12:36:49 PM)
Returns:
double