Class MoveLib

java.lang.Object
  extended byMoveLib
All Implemented Interfaces:
GameConstants

class MoveLib
extends java.lang.Object
implements GameConstants


Field Summary
static int BOWL_A
           
static int BOWL_B
           
static int BOWL_C
           
static int BOWL_D
           
private  java.util.Hashtable lib
           
static int[] MOVE_ROOT
           
private  int[] parent
          Parent is our linkage back to the previous move.
 
Constructor Summary
(package private) MoveLib()
          To ease some of the painful process of learning, we load the library with some of the more obvious moves.
 
Method Summary
(package private)  int getMove(int[] board)
          getMove attempts to look up a move in the library, based on the current state of the board.
(package private)  void lostGame()
          lostGame trims back the move tree to the last guess made.
(package private)  void resetParent()
           
(package private)  int storedMoves()
          This returns the stored move count, which is displayed on the game board.
 java.lang.String toString()
          This has proven useful in debugging and thus, has been left in.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

lib

private java.util.Hashtable lib

ran

private java.util.Random ran

parent

private int[] parent
Parent is our linkage back to the previous move. The value of the last move made will be added to the next in order to chain them together. This is used later when we have to purge branches of the tree that have proven themselves to be unuseful.


BOWL_A

public static final int BOWL_A
See Also:
Constant Field Values

BOWL_B

public static final int BOWL_B
See Also:
Constant Field Values

BOWL_C

public static final int BOWL_C
See Also:
Constant Field Values

BOWL_D

public static final int BOWL_D
See Also:
Constant Field Values

MOVE_ROOT

public static final int[] MOVE_ROOT

bowlName

public static final java.lang.String[] bowlName

bowlLabelLocation

public static final int[][] bowlLabelLocation
Constructor Detail

MoveLib

MoveLib()
To ease some of the painful process of learning, we load the library with some of the more obvious moves.

Method Detail

storedMoves

int storedMoves()
This returns the stored move count, which is displayed on the game board. In this way the user can see the move tree grow as moves are made, and shrink when the tree is pruned back.


toString

public java.lang.String toString()
This has proven useful in debugging and thus, has been left in.


resetParent

void resetParent()

getMove

int getMove(int[] board)
getMove attempts to look up a move in the library, based on the current state of the board. If none is found, a new random move is created, added to the library, and returned as if a move was found.


lostGame

void lostGame()
lostGame trims back the move tree to the last guess made. We flip it to force exploration of the untried branch.