You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.5 KiB
56 lines
1.5 KiB
|
|
//Main class and GUI
|
|
|
|
public class Chess {
|
|
private GameBoard board;
|
|
|
|
//User's first click for a move.
|
|
private Integer clickRow; //null means no first click made currently.
|
|
private Integer clickColumn;
|
|
|
|
private ArrayList<GameState> gameStateHistory; //Stack of GameBoard states for the move undo.
|
|
private ArrayList<Move> moveHistory; //Stack of tuples (moves) so they can be displayed.
|
|
private ArrayList<String> moveNotationHistory; //Stack of move notations.
|
|
|
|
public void start() {
|
|
//Set up graphics on the screen, buttons
|
|
//Set up the initial board
|
|
//Set up empty move history, game history, notation history.
|
|
//clickRow and clickCol are null
|
|
//Set up mouse/click events
|
|
}
|
|
|
|
//Reset to the intial game position.
|
|
public void reset() {
|
|
//Set up the initial board
|
|
//Clear out clickRo and clickCol
|
|
//Clera out all the histories.
|
|
}
|
|
|
|
//AI makes a move
|
|
public void moveAI() {
|
|
//Ask the gameState for a list of all legal moves.
|
|
//Get one of those in the list uniformly at random.
|
|
makeMove(...);
|
|
}
|
|
|
|
private void makeMove(...) {
|
|
//Clone the gameState object for the current state of the game, tell it to make the move, add it to the move history
|
|
//add the notation for it
|
|
//add the move to the history as well
|
|
}
|
|
|
|
//For the human moving
|
|
public void mouseClick() {
|
|
//If it is the first click (null check) then record it, updtae the GUI to show highlighting
|
|
//else attempt the move:
|
|
|
|
makeMove(...);
|
|
}
|
|
|
|
//Undo button for the most recent move
|
|
public void undo() {
|
|
//Pop those 3 history object things and update the GUI.
|
|
}
|
|
|
|
} |