CPSC170A Assignment 2
Chess

Due Feburary 8th, 2013

7  -   -   -   -   -   -   -   - 
6  -   -   -   -   -   -   -   - 
5  -   -   -   -   -   -   -   - 
4  -   -   -   -   -   -   -   - 
3  -   -   -   -   -   -   -   - 
2  -   -   -   -   -   -   -   - 
1  P0  P1  P2  P3  P4  P5  P6  P7
0  R0  K0  B0  Q   K   B1  K1  R1
   0   1   2   3   4   5   6   7 

  

For this assignment, you are going to implement a very relaxed version of a game of chess. There is no requirement for graphical component, so the main complexity is setting up your classes so that you can display a chess board, and then have pieces move on that chess board. If you are unfamiliar with the game of chess, or need a refresher on the movement rules, there is a good primer here.

Details

You are required to have several classes for this assignment. You will, at the very least, need a class that represents the game board, which facilitates writing the board tot he terminal. You will also need a class for each type of piece that makes up a chess game. Those pieces are:

In a full game of chess, there is a lot of complexity. We are going to remove basically all of it for the purposes of this program. You are only required to represent the basic movement of the pieces. So, for example, a pawn in your program is only permitted to move forward, and only one square at a time.

Each piece should have a way (given where it is expected to move to) to determine whether a move is valid or not. For a start, a new location is valid only if the new location is not occupied, and the location is reachable following the typical chess movement rules for that piece. You should make sure you can move the pieces correctly if they are the only piece on the board. Then you add additional pieces, to test your movement.

Once you have the basics of moving pieces around, then you can focus on getting the user to be able to control the pieces at runtime. You will need a menu loop, which will prompt the user for input twice. The user will first enter in the coordinate of the piece they want to move, and then the coordinate they want to move to.

You should spend some of time determining what attributes each of these classes require. You may be able to add additional classes that aid in the representation of the pieces and the board itself.

Submission: Submit your code, with your modified test cases, as a zip file with your name as the zip file name (FIRSTNAMELASTNAME.zip)on the course Inquire site by
5:00 PM February 8th, 2013.

Test Cases

You are required to submit at least three test cases for this program. Each test case should be written in a test_chess_#.py file. Each of your test cases will involve moving a different chess piece. For each test case, you are required to show:

Remember, these files do not need to run at the time of submission. They should demonstrate that you have put forward the effort to understand what the assignment has tasked you to do, and how your classes are going to be structured.

Submission: Submit your test_chess_#.py files, as well as another plain-text file with descriptions of the expected behavior of the test_chess_#.py programs, as a zip file (FIRSTNAMELASTNAME.zip) on the course inqiure website by 10:00 PM February 4th, 2013.

Extra

Additional Movement Constraints: The basics of movement of a single piece are not too difficult. The major complexity come in when multiple pieces exist on the board. Restrict movement for the pieces, so they obey some of the more complex moves. For example, the rook, bishop, and queen can only move to a grid location if that location is empty AND all locations on the path between them and the new location are empty.

Player 2: For two players, you will need to create two sets of pieces, and arrange the accordingly to the board. Your menu loop with then, prompt user one for their input, then user two. You will have to make sure user one only moves their pieces, and vice versa.

Capturing: If you have the two player version working, then it would be more exciting if the players could actually capture their opponents pieces.

Graphics: It isn't very exciting to look at a game of chess drawn to the terminal screen. Setup the game so that the board is drawn to a turtle window.