diff --git a/Day 43 (design chess application)/Chess.java b/Day 43 (design chess application)/Chess.java new file mode 100644 index 0000000..cdec6e2 --- /dev/null +++ b/Day 43 (design chess application)/Chess.java @@ -0,0 +1,30 @@ + +//Main class and GUI + +public class Chess { + private GameBoard board; + //Remembers the initial click square for the user's move + //Stack of GameBoard states for the move undo. + //Stack of tuples (moves) so they can be displayed. + + public void start() { + //Set up the initial board + } + + //Reset to the intial game position. + public void reset() { + } + + //AI makes a move + public void moveAI() { + } + + //For the human moving + public void mouseClick() { + } + + //Undo button for the most recent move + public void undo() { + } + +} \ No newline at end of file diff --git a/Day 43 (design chess application)/GameState.java b/Day 43 (design chess application)/GameState.java new file mode 100644 index 0000000..c314bd0 --- /dev/null +++ b/Day 43 (design chess application)/GameState.java @@ -0,0 +1,26 @@ + +public class GameState { + //Tracks the game board as a 1D array of Square objects (effectively 12 x 12) with 2 layers of sentinel squares all around. + //Knows whose turn it is + + public GameState() { + + reset(); + } + + public void reset() { + } + + public void attemptMove(int sourceX, int sourceY, int destX, int destY) { + //See if it is legal. + //Change the board state accordingly. + } + + public Moves[] getAllPossibleMoves() { + } + + // returns something like "checkmate", "stalemate", etc. + public String getFeedback() { + } + +} diff --git a/Day 43 (design chess application)/Move.java b/Day 43 (design chess application)/Move.java new file mode 100644 index 0000000..db18041 --- /dev/null +++ b/Day 43 (design chess application)/Move.java @@ -0,0 +1,13 @@ + +public class Move { + //source and dest coordinates + //boolean check or not + //boolean capture or not + //boolean checkmate or not + + + //returns something like e2-e4 or Qc8++ + public String toString() { + } + +} diff --git a/Day 43 (design chess application)/Square.java b/Day 43 (design chess application)/Square.java new file mode 100644 index 0000000..42fbc2c --- /dev/null +++ b/Day 43 (design chess application)/Square.java @@ -0,0 +1,12 @@ + +public class Square { + //Pawn, knight, bishop, rook, queen, king, blank. + //White or black boolean + //en passant boolean flag (for the square that would be "captured") + //boolean Knowledge of whether or not this piece moved yet (for castling) + //boolean for off-the-board square + + //Positive values for white, negative for black, blank square is 0. + public int getValue() { + } +} \ No newline at end of file diff --git a/Day 43 (design chess application)/chess program design.txt b/Day 43 (design chess application)/chess program design.txt index 5b0737e..0fff105 100644 --- a/Day 43 (design chess application)/chess program design.txt +++ b/Day 43 (design chess application)/chess program design.txt @@ -5,16 +5,18 @@ Possible classes: Show the list of moves that are performed so far Show the captured pieces Show highlighting for the most recent move - GameBoard + Symbol for display? + GameState Direct storage of piece data in a 2D array (speed of computation) - Knowledge of whether or not castling, en passant are available + Know whose turn it is Be able to set up the starting positions - Perform the move (remove piece if a capture, promote to queen if get to the end) - Piece (subclasses?) - Symbol - Position (else captured) - Player - Enacts moves on the GameBoard + Be able to perform the move (remove piece if a capture, promote to queen if get to the end) + Square + What pieces (if any) occupies it + Knowledge of whether or not castling, en passant are available + Move + Represents a source and destination square + Knows whether or not it was a capture, check, etc. Where are the rules going to be programmed in? A piece has to be aware of other stuff going on around it in order to calculate if a move is legal or not. diff --git a/Day 43 (design chess application)/requirements and spec.txt b/Day 43 (design chess application)/requirements and spec.txt index b4cc9aa..ceacff0 100644 --- a/Day 43 (design chess application)/requirements and spec.txt +++ b/Day 43 (design chess application)/requirements and spec.txt @@ -4,7 +4,9 @@ This simple application allows the user to play chess. Moves can be made by hum GUI === -The GUI shows a 2D grid of colored chess squares and whichever pieces are in play (it starts with a new game, ready to play). +The GUI shows a 2D chess board and whichever pieces are in play (it starts with a new game, ready to play). + Last move and currently selected square are highlighted in different colors. + List of all moves made so far in the game are listed on the side. Text feedback is given for the game state (who's turn it is, and if it is checkmate or stalemate).