Class Board

java.lang.Object
  |
  +--Board

public class Board
extends java.lang.Object

This is the board object that will hold references to pieces in the arrangement they are found on the chess board. It is implemented using an array of ChessPiece references. It also has a copy() method that is used to make copies of it for the tree used in deciding how to move.


Field Summary
protected  ChessPiece[][] board
          This is the array of ChessPieces.
 
Constructor Summary
Board()
          Builds a new board setup to start a new game of chess.
Board(Board b)
          Builds a new board based on the given board.
 
Method Summary
 Board copy()
          Returns a field for field copy of this object.
 int evaluate()
          Returns the current material value of the board.
 ChessPiece getPiece(int row, int col)
          Returns the piece at the specified location.
 void movePiece(Move theMove)
          Makes a move according to the specified Move object, taking pieces if needed (by simply overwriting their spot in the array), leaving a null reference behind where the piece was originally located.
protected  void setPiece(int row, int col, ChessPiece piece)
          Used to add pieces to the board.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

board

protected ChessPiece[][] board
This is the array of ChessPieces. It is an 8 by 8 array of ChessPiece references. Nothing more, nothing less.

Constructor Detail

Board

public Board()
Builds a new board setup to start a new game of chess.


Board

public Board(Board b)
Builds a new board based on the given board. This constructor is used in copy().

Method Detail

getPiece

public ChessPiece getPiece(int row,
                           int col)
Returns the piece at the specified location.


setPiece

protected void setPiece(int row,
                        int col,
                        ChessPiece piece)
Used to add pieces to the board. Should only be needed by the constructors and the copy() method.


movePiece

public void movePiece(Move theMove)
Makes a move according to the specified Move object, taking pieces if needed (by simply overwriting their spot in the array), leaving a null reference behind where the piece was originally located.


evaluate

public int evaluate()
Returns the current material value of the board. Treating white pieces as negetive and black as positive.


copy

public Board copy()
Returns a field for field copy of this object. It calls the copy() method of ChessPiece, making copies of the pieces on the board as well. This is so the entire board can be manipulated independently from the actual chess board.