coding project and no UI/UX needed it's undergrad class project so senior software developer level of skills are not needed./n 2/13/24, 2:34 AM CS 213 Spring 2024: Assignment 1 For this assignment you will explore how to apply the object-oriented design ideas you learned in class to design and implement the chess game. You will work on this assignment in pairs. Assignment 1 2-Player Chess We will NOT be using Autolab for assignments. So your submission will be graded once, after the deadline has passed. Your submission will be AUTOGRADED, so be careful to follow implementation instructions (and constraints) exactly as detailed. There will NOT be any manual inspection of your code, nor will be there any manual inspection of anything your code might print. All credit is solely for structures that are returned from methods that are called on your program by the AUTOGRADER, and checked by the AUTOGRADER against the expect correct structures. Read the DCS Academic Integrity Policy for Programmming Assignments - you are responsible for this. In particular, note that "All Violations of the Academic Integrity Policy will be reported by the instructor to the appropriate Dean". • Board Move Ending the game Implementation Grading Submission FAQs You will implement the game of Chess for two players. Your program, when launched, should draw the board in text, on the terminal and prompt whomever's turn it is (white or black) for a move. Once the move is executed, the move should be played and the new board drawn, and the other player queried. ● Board The figure below depicts a chess board. Every square on the board is identified in the form of FileRank where the File is a column from a thru h, and the Rank is a row from 1 to 8. So, for instance, the square g5 is in column g, row 5. The white pieces always intially occupy ranks 1 and 2. The black pieces always initially occupy ranks 7 and 8. The queen always starts on the d file. https://www.cs.rutgers.edu/courses/213/classes/spring_2024_venugopal/chess/chess.html 1/10 2/13/24, 2:34 AM 8 a 6 5 4 a4 b4 c4 d4 3 a3 b3 c3 d3 2 a2 b2 c2 d2 1 al bl cl d1 b a b c d e f g h e2 e4 g8 h6 f1 c4 c7 c5 ● •+11 coa e2 e4 e7 e5 resign co • Draw g5 de f g h 7 Move A game must always start with a move by the player who is playing white. A piece is moved from one square to another using the notation FileRank FileRank, so for example, when the game starts, the move "e2 e4" would move the white pawn from e2 to e4. Here's a sample sequence of alterating white and black moves: -5 3 2 Special Move Formats The following moves require a special reading of the format: Castling A castling move is indicated by specifying where the king begins and ends. So, white castling king's side would be "e1 g1". • Pawn promotion A pawn promotion is indicated by putting the piece to be promoted to after the move. So, promoting a pawn to a knight might be "g7 g8 N". (Rook is R, bishop is B). If no promotion piece is indicated, it is assumed to be a queen. (Although you can explicitly ask for a queen promotion, as in "g7 g8 Q", it is discouraged.) Resign A player may resign by simply issuing the move "resign". Here's an example of a sequence of moves that ends with white resigning: CS 213 Spring 2024: Assignment 1 https://www.cs.rutgers.edu/courses/213/classes/spring_2024_venugopal/chess/chess.html 2/10 2/13/24, 2:34 AM ● A player may ask for a draw like this: e2 e4 e7 e5 g1 f3 draw? Unlike "resign" which is a move all by itself, a draw is asked for by appending "draw?" to an otherwise regular move. Consequently, the move is first carried out, and then the draw is applied. Illegal Moves ● Every piece must know what moves are allowed on it. If a player attempts an illegal move on a piece, the move should not be executed. • A piece cannot be moved in a way that would immediately put that player's king under check by the opponent: CS 213 Spring 2024: Assignment 1 g2 g3 e7 e6 g1 h3 f8 b4 d2 d3 The white move "d2 d3" would put the white king in check from the black bishop. So it is an illegal move that should not be allowed. Note that when a player makes an illegal move, it's still their turn until they make a legal move. Ending the game The game may end in one of the following ways: Checkmate The player that applies the checkmate wins. Resign A player may resign as described in the previous section. The other player wins. • Draw A player may offer a draw as descried in the previous section. For the purpose of this assignment, the other player is obligated to accept the draw, even if the player who proposes a draw might be in a losing position. Note: There will be no automatic draws (due to unchangeing positions over long periods of time, etc). You are NOT required to implement termination by threefold repetition, or the fifty-move rule. (You are welcome to include them in your code to make it complete; however, there is no extra credit for either.) Implementation https://www.cs.rutgers.edu/courses/213/classes/spring_2024_venugopal/chess/chess.html 3/10 2/13/24, 2:34 AM CS 213 Spring 2024: Assignment 1 You will implement your code in as many classes as you would like, with the following constraints: 1. All your classes must be in a package named chess. Otherwise we will not be able to grade your program. 2. One of your classes must be the supplied Chess class in Chess.java, which is in the chess package. (See the line at the top of the file that says package chess). In Chess.java, you will fill in the code for the start and play methods. Our grading script will ONLY call these methods. 3. You will NOT write a main method in any of your classes. Instead, you may use the supplied PlayChess application in PlayChess.java, which is in the chess package. This class has a main method that you can use to test your implementation. 4. Do NOT delete or modify any of the original contents of Chess.java: • Do NOT change the ReturnPiece and ReturnPlay classes in ANY way. o Do NOT change the enum Player in ANY way. • Do NOT change the headers of the play and start methods in ANY way. 5. You may add fields and methods to the Chess class as needed. 6. You may also add imports to Chess.java, as long as they are from the standard Java SDK (not an external vendor). Breaking any of these constraints will make your submission ungradable, and will result in a significant penalty on your score. If you don't know how to make a package named chess and place the given Chess.java and PlayChess.java in it, use ChatGPT or any other online resource to find out. You are responsible for figuring this out and doing it correctly in your development environment. Development Environment You may use any Java development environment you are comfortable with, such as Eclipse, NetBeans, IntelliJ, VS Code, etc. Since you will be submitting only source code in the standard Java package structure, what environment you use is not of any consequence to the submission. Howeever, whatever environment you choose, you are fully responsible for knowing how to use it to develop Java applications. This assignment and other assignments in this class may require you to broaden your knowledge in this regard, so you might need to learn how to do certain things yourself by looking up resources online. We all use different environments in general, so if you run into trouble with yours, there is no guarantee that we can help you because we may have never used your environment to build Java applications. Returning a result from the Chess.play method The supplied Chess.java file contains three classes: the Chess class, and two other classes, ReturnPiece and ReturnPlay. These two classes are specifically set up to return the result of executing the Chess.play method. https://www.cs.rutgers.edu/courses/213/classes/spring_2024_venugopal/chess/chess.html 4/10 CS 213 Spring 2024: Assignment 1 ReturnPiece encapsulates a piece on the board, and ReturnPlay encapsulates the collection of all pieces on the board, plus a message that could be null, or could be one of the messages in the Message enumeration. 2/13/24, 2:34 AM The following table gives examples of all scenarios for different return values when Chess.play is executed on a move. Scenario Legal move not resulting in a check Legal move resulting in a check Legal move resulting in a checkmate Illegal move Draw Resign Return ReturnPlay instance with pieces on board after move is executed, null message ReturnPlay instance with pieces on board after move is executed, message is CHECK ReturnPlay instance with pieces on board after move is executed, message is CHECKMATE_WHITE_WINS or CHECKMATE_BLACK_WINS e2 e4 ReturnPlay instance with pieces on board same as previous state of the board (since move is not executed) message is ILLEGAL MOVE ReturnPlay instance with pieces on board after move is executed (e.g. in "e2 e4 draw?", the move "e2 e4" is executed before draw) message is DRAW ReturnPlay instance with pieces on board same as previous state of the board (since move is not executed) message is RESIGN_BLACK_WINS (if white resigned) or RESIGN_WHITE_WINS (if black resigns) Restarting the game from scratch The Chess.start is to be called any time you want to start/restart the game from scratch. This is useful to try a sequence of moves, then reset with start for a new sequence from scratch. IMPORTANT: When we test your submission, the AUTOGRADER will execute several games from scratch. Every time it executes a new game, it will first call your Chess.start() method (which should reset the games to the starting start), and then execute moves. See the sample run in the next section for an illustration. The PlayChess application You can use this application to test your implementation, by making calls to Chess.start and Chess.play Here is a sample run of PlayChess: bR bN bB bQ bk bB bN bR 8 bp bp bp bp bp bp bp bp 7 ## 6 ## ## ## https://www.cs.rutgers.edu/courses/213/classes/spring_2024_venugopal/chess/chess.html 5/10
Fig: 1