referee
Class Board

java.lang.Object
  extended by referee.Board

public class Board
extends java.lang.Object

Title: Board

Description: Represents a checker position

Copyright: Copyright (c) 2004

Company: Eastern Michigan University

Version:
1.0
Author:
Matthew Evett

Field Summary
static int BLACK_KING
          In an array of ints, ARR, representing a board position, this value at ARR[i] indicates that there is a black king at position i.
static int BLACK_PAWN
          Indicates there is a black pawn at position i.
static int NO_PIECE
          Indicates there is no piece at position i.
static int NUM_SQUARES
          Number of legal positions on a game board
static int WHITE_KING
          Indicates there is a white king at position i.
static int WHITE_PAWN
          Indicates there is a white pawn at position i.
 
Constructor Summary
Board()
          Generates a starting board.
Board(Board orig)
          Copy constructor.
Board(int[] boardArr, boolean isWhitePlayer)
          Constructs a board with pieces arranged as specified by boardArr.
 
Method Summary
 boolean isNoLegalMove()
           
 boolean isWhitesMove()
           
static void main(java.lang.String[] args)
           
 int numBlacks()
          numBlacks
 int numWhites()
          numWhites
 int[] toArray()
          toArray
 java.lang.String toString()
           
 java.lang.Object updateBoard(int[] move)
          Modify the board to reflect the given move.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NUM_SQUARES

public static final int NUM_SQUARES
Number of legal positions on a game board

See Also:
Constant Field Values

BLACK_KING

public static final int BLACK_KING
In an array of ints, ARR, representing a board position, this value at ARR[i] indicates that there is a black king at position i.

See Also:
Constant Field Values

NO_PIECE

public static final int NO_PIECE
Indicates there is no piece at position i.

See Also:
Constant Field Values

WHITE_PAWN

public static final int WHITE_PAWN
Indicates there is a white pawn at position i.

See Also:
Constant Field Values

WHITE_KING

public static final int WHITE_KING
Indicates there is a white king at position i.

See Also:
Constant Field Values

BLACK_PAWN

public static final int BLACK_PAWN
Indicates there is a black pawn at position i.

See Also:
Constant Field Values
Constructor Detail

Board

public Board()
Generates a starting board. Black pawns occupy spaces 1-12, white pawns occupy spaces 21-32.


Board

public Board(Board orig)
Copy constructor.

Parameters:
orig - Board

Board

public Board(int[] boardArr,
             boolean isWhitePlayer)
Constructs a board with pieces arranged as specified by boardArr. It will be White's turn if isWhitePlayer is true, otherwise it is Black's turn.

Parameters:
boardArr - int[]
isWhitePlayer - boolean
Method Detail

isWhitesMove

public boolean isWhitesMove()
Returns:
True if it is white's move

updateBoard

public java.lang.Object updateBoard(int[] move)
Modify the board to reflect the given move. Move is a sequence (stored in an array) of board positions. A single move will consist of just two integers = the first and last positions. E.g: 6, 1. Jumps may consist of longer sequences, providing that the "skipped" position contained an opposition piece. E.g: 10, 1. Jumps may be concatenated, forming longer sequences: e.g.: 17, 10, 1 * @author Matthew Evett

Returns:
board resulting from the move, or a String indicating why it was illegal

numWhites

public int numWhites()
numWhites

Returns:
Number of white pieces on the board

numBlacks

public int numBlacks()
numBlacks

Returns:
Number of black pieces on the board

toArray

public int[] toArray()
toArray

Returns:
int[] The board's position encoded as an array, b, where b[i] encodes the piece at position i on the board (b[i] = -2 for black king, -1 for black pawn, 1 for white pawn, 2 for white king, and 0 if position i is unoccupied.) b[0] is unused.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
String that is a printable representation of the board position.

main

public static void main(java.lang.String[] args)

isNoLegalMove

public boolean isNoLegalMove()
Returns:
True if there is no legal move for the current player.