edu.gwu.champAlg
Class ChessBoard

java.lang.Object
  extended by edu.gwu.champAlg.ChessBoard

public class ChessBoard
extends java.lang.Object

This class handles all the moves related to the board. There are a couple of useful methods you can call, but most importantly, you can view the board, which is of type char[][]. White has pieces 'K', 'Q', 'R', 'B', and 'P' while Black has pieces 'k', 'q', 'r', 'b' and 'p'.


Field Summary
 char[][] board
          The state of the board.
 boolean testKingCheck
          If "false" we leave it to the players to test.
 
Constructor Summary
ChessBoard()
           
ChessBoard(char[][] origBoard)
           
 
Method Summary
 ChessBoard copy()
          This makes a copy of the chessboard, useful in exploring a tree.
 java.util.ArrayList<ChessMove> getLegalMoves(int x, int y)
          Return a list of legal moves for the piece at (x,y)
 boolean isGameOver()
           
 java.lang.String testAndMove(ChessMove move, boolean isWhite)
           
 boolean valid(int x, int y)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

board

public char[][] board
The state of the board. The board[x][y] is such that x goes left to right and y from bottom to top, exactly as in Cartesian coordinates.


testKingCheck

public boolean testKingCheck
If "false" we leave it to the players to test. That is, we don't test whether the King is in check.

Constructor Detail

ChessBoard

public ChessBoard()

ChessBoard

public ChessBoard(char[][] origBoard)
Method Detail

copy

public ChessBoard copy()
This makes a copy of the chessboard, useful in exploring a tree.

Returns:
a ChessBoard value

getLegalMoves

public java.util.ArrayList<ChessMove> getLegalMoves(int x,
                                                    int y)
Return a list of legal moves for the piece at (x,y)

Parameters:
x - an int value
y - an int value
Returns:
an ArrayList value

testAndMove

public java.lang.String testAndMove(ChessMove move,
                                    boolean isWhite)

isGameOver

public boolean isGameOver()

valid

public boolean valid(int x,
                     int y)