[SOLVED] CS213 Assignment 2- Chess

35.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You will receive the following solution file(s) instantly after successful payment:

zip file icon Assignment-2-Chess-qym0sp.zip (356.8 KB)
Assignment Instructions Updated Recently? Submit Below and we will provide new Solution!
Submit New Instructions
🔒 Securely Powered by:
Secure Checkout
5/5 - (4 votes)

Note that you will be maintaining your code in Bitbucket, which is a source code repository. Learning how to manage your source code INCREMENTALLY and in COLLABORATION with your project partner is an important skill, and Bitbucket (like Github) is a code repository that allows you to do this effectively.

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.

 

Output

The board should be drawn on the screen with ascii art EXACTLY as shown in this example. Note there is a blank line above and below any prompt/message your program will print, and the board itself.

You will NOT use a graphical user interface, that is not the point of this assignment. If you do, your submission will NOT be graded.

You MUST have white make the first move. Having black make the first move is not appropriate, and will incur a penalty.

Note:

  • Every piece must know what moves are allowed on it. If a player attempts an illegal move on a piece, your program should not execute the move. Instead, it should print “Illegal move, try again”, followed by the usual prompt (for white’s move or black’s move).

You don’t need to have a blank line between an attempted move, the illegal move warning, and the actual correct move. You only need to have a blank line between the board drawing and a move.

  • When a move is made, and it puts the opponent’s King under check, your program should print “Check” before prompting for the opponent’s move.
  • If a checkmate is detected, your program should print “Checkmate”
  • The last thing before termination should be a display of “Black wins”, “White wins” or “draw”.

Input

Your program needs to accept input of the form “FileRank FileRank”, where the first file (column) and rank (row) are the coordinates of the piece to be moved, and the second file and rank are the coordinates of where it should end up. (See the board example shown above.) All inputs will be on the command line, one move at a time, not through a file.

The figure immediately below should make it clear which rank and file combinations belong to which squares. The white pieces always initially occupy ranks 1 and 2. The black pieces always initially occupy ranks 7 and 8. The queen always starts on the d file.

 

As an example, advancing the white king’s pawn two spaces would be input as “e2 e4”.

A castling move is indicated by specifying where the king begins and ends. So, white castling king’s side would be “e1 g1”.

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”. If no promotion piece is indicated, it is assumed to be a queen.

Example of black winning

Ending the game

  • If checkmate occurs, the game shall end immediately with the result reported.
  • A player may resign by entering “resign”.

o Example of white resigning o Example of black resigning

  • A player may offer a draw by appending “draw?” to the end of an otherwise regular move. When a draw is offered, the other player is obligated to accept, and the game ends, whatever the actual situation may be. (No justification is needed.) So the other player will simply submit “draw” as the entirety of their next move. There will be no automatic draws (due to unchangeing positions over long periods of time, etc). oExample of a draw

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.)

  • Assignment-2-Chess-qym0sp.zip