Class MancalaNode

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

public abstract class MancalaNode
extends GameNode

MancalaNode - a mancala game node


Field Summary
protected  int[] state
           How to interpret the Mancala state variable: Let the mancala pits be notated thus: f e d c b a g G A B C D E F where A-F are the first player's (MAX's) pits, G is the first player's (MAX's) scoring pit, a-f are the second player's (MIN's) pits, and g is the second player's (MIN's) scoring pit.
 
Fields inherited from class GameNode
parent, player, prevMove
 
Constructor Summary
MancalaNode()
           
 
Method Summary
 java.lang.Object clone()
          clone - return a deep clone of the MancalaNode.
 boolean gameOver()
          gameOver - return true if no pieces left in play pits.
 int[] getLegalMoves()
          Return an array of legal mancala moves.
 void initialState()
          Set initial Mancala state.
 void makeMove(int move)
          Make the designated move, redistributing pieces from the indicated position and updating player accordingly.
static java.lang.String moveToString(int move)
          Translates move integer to a String.
 java.lang.String toString()
          String representation of current game state.
abstract  double utility()
          Return an estimation of game node utility, unless game is over.
 
Methods inherited from class GameNode
childClone, expand, getPlayer
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

state

protected int[] state
 
How to interpret the Mancala state variable:

Let the mancala pits be notated thus:

f e d c b a
g             G
A B C D E F

where 
A-F are the first player's (MAX's) pits,
G is the first player's (MAX's) scoring pit,
a-f are the second player's (MIN's) pits, and 
g is the second player's (MIN's) scoring pit.

The numbers of pieces in each pit are stored in an array asa follows:
state[0] ... state[6] store the number of pieces in A ... G.
state[7] ... state[13] store the number of pieces in a ... g.

Each player's goal is to end the game with more pieces in one's own
scoring pit.  Thus a simple measure of utility would be (G - g).
Constructor Detail

MancalaNode

public MancalaNode()
Method Detail

clone

public java.lang.Object clone()
clone - return a deep clone of the MancalaNode.
Overrides:
clone in class GameNode
Returns:
an Object value - a deep clone of the MancalaNode.

gameOver

public boolean gameOver()
gameOver - return true if no pieces left in play pits.
Overrides:
gameOver in class GameNode
Returns:
a boolean value

initialState

public void initialState()
Set initial Mancala state. Creation date: (10/6/00 12:39:32 PM)
Overrides:
initialState in class GameNode

getLegalMoves

public int[] getLegalMoves()
Return an array of legal mancala moves. Creation date: (10/6/00 1:12:37 PM)
Overrides:
getLegalMoves in class GameNode
Returns:
int[]

makeMove

public void makeMove(int move)
Make the designated move, redistributing pieces from the indicated position and updating player accordingly. Creation date: (10/6/00 1:51:59 PM)
Overrides:
makeMove in class GameNode
Parameters:
move - int

moveToString

public static java.lang.String moveToString(int move)
Translates move integer to a String. Creation date: (10/11/00 8:50:12 PM)
Returns:
java.lang.String

toString

public java.lang.String toString()
String representation of current game state. Example (initial state): f e d c b a ------------------------- | | 4| 4| 4| 4| 4| 4| | | 0|-----------------| 0| | | 4| 4| 4| 4| 4| 4| | <-- ------------------------- A B C D E F Creation date: (10/7/00 4:03:47 PM)
Overrides:
toString in class java.lang.Object
Returns:
java.lang.String

utility

public abstract double utility()
Return an estimation of game node utility, unless game is over. If game is over, return actual utility. NOTE: In your implementation, you must create your own subclass of MancalaNode (e.g. UserIDMancalaNode extends MancalaNode) and implement this utility method (inheriting all others). This can be confusing if you don't know Java well, so see the example I've provided with TnellerMancalaNode. Example implementation: public double utility() { return state[MAX_SCORE_PIT]-state[MIN_SCORE_PIT]; } Creation date: (10/6/00 1:22:26 PM)
Overrides:
utility in class GameNode
Returns:
double