java.lang.Objectedu.gwu.champAlg.ChessBoard
public class ChessBoard
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 |
---|
public char[][] board
public boolean testKingCheck
Constructor Detail |
---|
public ChessBoard()
public ChessBoard(char[][] origBoard)
Method Detail |
---|
public ChessBoard copy()
ChessBoard
valuepublic java.util.ArrayList<ChessMove> getLegalMoves(int x, int y)
x
- an int
valuey
- an int
value
ArrayList
valuepublic java.lang.String testAndMove(ChessMove move, boolean isWhite)
public boolean isGameOver()
public boolean valid(int x, int y)