public class Board
extends java.lang.Object
| Modifier and Type | Field and Description | 
|---|---|
static int | 
BLACK  | 
static int[] | 
INITIAL_COLORS  | 
static int[] | 
INITIAL_LOCATIONS  | 
static int[] | 
INITIAL_NUMBERS  | 
static int | 
NEITHER  | 
static int | 
NUM_SPIKES  | 
static int | 
WHITE  | 
| Modifier | Constructor and Description | 
|---|---|
  | 
Board()
Constructor, build an newly initialzed board 
 | 
protected  | 
Board(Board other)
Constructor, builds a copy of the given board 
 | 
| Modifier and Type | Method and Description | 
|---|---|
boolean | 
equals(java.lang.Object o)
Public equals 
 | 
int | 
getBar(int color)
Returns the number of pieces on the bar of the
 given color. 
 | 
static int | 
getBase(int color)
Returns the home location of the given color
 (the location where the color wants to move it's
 pieces). 
 | 
int | 
getBlackBar()
Returns the number of black pieces on the bar. 
 | 
int | 
getBlackOff()
Returns the number of black pieces beared off 
 | 
int | 
getBlackPieces(int location)
Returns the number of black pieces at the given location. 
 | 
int | 
getBlackPips()
Returns the number of black pips left 
 | 
int | 
getColor(int location)
Returns the color of the pieces at the given location 
 | 
static int | 
getDirection(int color)
Returns the direction of the given color
 (the direction where the color wants to move it's
 pieces). 
 | 
int | 
getOff(int color)
Returns the number of pieces beared off of the
 given color. 
 | 
static int | 
getOtherPlayer(int color)
Returns the other player 
 | 
int | 
getPieces(int location)
Returns the number of pieces at the given location 
 | 
int | 
getPieces(int color,
         int location)
Returns the number of pieces at the given location an
 of the given color. 
 | 
int | 
getPips(int color)
Returns the number of pips for the
 given color. 
 | 
Board | 
getScratch()
Returns a scratch copy of the board, which is a clone and
 can be changes without any problems. 
 | 
int | 
getWhiteBar()
Returns the number of white pieces on the bar. 
 | 
int | 
getWhiteOff()
Returns the number of white pieces beared off 
 | 
int | 
getWhitePieces(int location)
Returns the number of black pieces at the given location. 
 | 
int | 
getWhitePips()
Returns the number of white pips left 
 | 
int | 
getWinner()
If the game is over, this returns the winner 
 | 
protected int | 
hash(int base,
    int[] array)  | 
int | 
hashCode()
Returns the hashCode of this move 
 | 
static boolean | 
inHomeQuadrant(int location,
              int color)
Method which returns whether or not the given spike is in the
 given player's home square. 
 | 
protected static boolean | 
isBetween(int location,
         int a,
         int b)
Method which checks to see if the location is between the other
 two locations. 
 | 
static boolean | 
isEqual(int[] a,
       int[] b)
Utility function to detect equality 
 | 
boolean | 
isGameOver()
Returns whether or not the game is over 
 | 
void | 
moveOff(int color)
Moves a piece off of the given color 
 | 
void | 
moveToBar(int color)
Moves a piece to the bar of the given color 
 | 
void | 
moveToLocation(int color,
              int location)
Moves a piece to the given location of the given color 
 | 
static boolean | 
onBoard(int location)
Internal method which returns whether or not the given
 location is on the board 
 | 
void | 
print(java.io.PrintStream out)
Prints out a gnubg-style text board. 
 | 
protected void | 
print(java.io.PrintStream out,
     int location,
     int count)
Internal method to print a piece and location 
 | 
void | 
removeFromBar(int color)
Removes a piece from the bar of the given color 
 | 
void | 
removeFromLocation(int color,
                  int location)
Removes a piece from the given location of the given color 
 | 
void | 
reset()
Resets the pieces on the board to their initial configurations 
 | 
public static final int NUM_SPIKES
public static final int WHITE
public static final int BLACK
public static final int NEITHER
public static final int[] INITIAL_LOCATIONS
public static final int[] INITIAL_NUMBERS
public static final int[] INITIAL_COLORS
public Board()
protected Board(Board other)
public boolean equals(java.lang.Object o)
equals in class java.lang.Objectother - To compare topublic static boolean isEqual(int[] a,
              int[] b)
a - The frist arrayb - The second arraypublic int hashCode()
hashCode in class java.lang.Objectprotected int hash(int base,
       int[] array)
public Board getScratch()
public int getWinner()
public boolean isGameOver()
public void reset()
public int getColor(int location)
location - The locationpublic int getPieces(int location)
location - The locationpublic int getBlackPieces(int location)
location - The locationpublic int getWhitePieces(int location)
location - The locationpublic int getPieces(int color,
            int location)
color - The colorlocation - The locationpublic int getBlackBar()
public int getWhiteBar()
public int getBar(int color)
color - The colorpublic int getBlackOff()
public int getWhiteOff()
public int getOff(int color)
color - The colorpublic int getBlackPips()
public int getWhitePips()
public int getPips(int color)
color - The colorpublic static int getBase(int color)
color - The colorpublic static int getDirection(int color)
color - The colorpublic static int getOtherPlayer(int color)
color - The colorpublic static boolean onBoard(int location)
location - The location to check forpublic void moveToLocation(int color,
                  int location)
                    throws IllegalMoveException
color - The color to movelocation - The location to moveIllegalMoveExceptionpublic void removeFromLocation(int color,
                      int location)
                        throws IllegalMoveException
color - The color to removelocation - The location to removeIllegalMoveExceptionpublic void moveToBar(int color)
color - The color to movepublic void removeFromBar(int color)
                   throws IllegalMoveException
color - The color to removeIllegalMoveExceptionpublic void moveOff(int color)
color - The color to movepublic static boolean inHomeQuadrant(int location,
                     int color)
location - Th elocationcolor - The playerprotected static boolean isBetween(int location,
                int a,
                int b)
location - The location to checka - The first locationb - The second locationpublic void print(java.io.PrintStream out)
out - The output stream to write the board toprotected void print(java.io.PrintStream out,
         int location,
         int count)
out - The streamlocation - The locationcount - The count number