CS 350, Section 701
Winter, 2002.
Programming Project #2
Due 11pm, February 5th, 2002 via email:
Anatoly Khusid ()
Problem description:
Implement a Chess system. Notice: you do not need to implement search and game play. The system is to read in the file of game plays and simulate each game in the file, i.e. for each move made by a player, validate the move to make sure it is legal and then output the state of the board after the move is made. If any illegal moves are made, message is printed out and the game is aborted. If a pawn is in the position to be promoted, always assume it gets promoted to a Queen. You do not need to worry about castling or En Passant. You also do not need to check if you are jeopardizing your king or if the board is in a state of check or checkmate. If you do not know how a game of chess is played, here is a good webpage. (http://www.princeton.edu/~jedwards/cif/intro.html). There are many other resources online describing rules of chess, initial positions, etc.
You must use inheritance and polymorphism for designing and implementing chess figures hierarchy. Polymorphism must be used to verify each player’s move for the particular chess figure. Inheritance and polymorphism will be covered during 4th week of classes.
Input
The input files are input1, input2, input3, input4, and input5. The format is as follows: each file contains one game. Each line starts with a number followed by a dot (.) and a space. The following is a letter signifying which piece is being moved according to the following convention:
P - Pawn
R - Rook
Q - Queen
K - King
N - Knight
B - Bishop
Each line contains moves of both opponents, white, then black. The letter signifying the piece to move is followed by a letter-digit combination identifying the current position of that piece. The next character is a space, followed by a letter-digit combination identifying where the piece is being moved.
Thus Pe2 e4 means we are moving a pawn from e2 to e4.
After that the move of the first (white) opponent is complete and the move of the next opponent follows, preceded by a space, dash, space combination. The move of the second (black) opponent is identified in the same way.
Thus,
1. Pe2 e4 - Pe7 e5
means that at the first exchange of moves, white moved a pawn from e2 to e4, after which black moved a pawn from e7 to e5.
Output
For each exchange of moves (assuming they are legal), output the resulting chessboard. You can come up with your own output format if you want, otherwise a text-based output is accepted. Here is an example of the text-based output and an actual view of the board:
Text-based version:
a b c d e f g h
8 r q r b k
7 b p p
6 p p n p
5 n p p p
4 P P
3 P N N P
2 P P B P P
1 R B Q R K
Here we follow the same convention for identifying pieces as in the input file, except that all white pieces are upper case, while all black pieces are lower case letters.
Appropriate use of classes from the Standard Template Library (e.g. Vectors, Sets, etc.) is expected. You are also expected to follow the programming guidelines of Reiss in chapter 4, for example, the access of objects exclusively through the use of pointers. For more information please read section “Word of advice” at the end of this document.
What you need to do in your main() (driver.C):
Demonstrate that your Chess Simulation program works by processing each sample file included with your assignment, and saving your output into output files (output1.txt, output2.txt, output3.txt, output4.txt, and output5.txt)
You will need to submit your program output together with your program source.
What you need to submit:
1) Readme file (10% of the total grade). Don’t use html, must be simple Unix text file!
a. Description of your program functionality, how to compile and run.
(1-2 paragraphs the most)
b. How did you design and structure your program. Explain your reasoning for making specific design choices and considerations.
(1-2 paragraphs the most!)
c. Briefly describe each class in your program, why did you choose it.
d. Describe your class relationships. Name classes and corresponding relationships among them (aggregation, association, inheritance)
2) All the source code, Readme file, Makefile, and your program output (sample run) in output1.txt-output5.txt files. You do not need to submit your input files; I already have the input files, and will use them to test your program.
Grading criteria:
1) Overall OOP Design 40%. This is the most important part of your project.
a. Class choices, appropriate level of abstraction and encapsulation of data in each class. Cohesive choice of class methods within the class, and simplicity of class interfaces.
b. Appropriate Class relationships, lose coupling between classes.
c. Appropriate use of inheritance and polymorphism.
d. Simplicity of overall design.
2) Appropriate coding style and comments 10%
3) Program correctness and complete fulfillment of all program requirements 40%
4) Questions in your Readme file 10%.
Word of advice: Clever OO Design is a key to your success in this course. You should allocate plenty of time to produce clean and simple OO Design.
1) You should select an appropriate set of C++ classes to effectively solve the complexity of the programming problem. Remember that the choice of objects is very important whenever you attempt to solve the complexity of a large-scale programming project. You might want to consider using noun/verb technique for identifying potential class candidates for your OO Design. This technique is suggested in your textbook
2) You should use an appropriate level of abstraction for each object to create an illusion of simplicity in your OO design.
3) Each class must have simple, consistent, convenient, and cohesive interface for the outside world (class users). Objects must protect their attributes/data and hide internal details (such as algorithms) from the outside world.
4) Objects must communicate together through well-defined interfaces, using weak intra-class coupling. This means that your classes must have very limited or almost no intra-dependencies with one another. Example: Radio in my car has no relationship (dependence) with the engine in my car. This implies that there is no coupling (or very weak) between the radio and engine objects.
5) Clean, simple, and well-thought OO design will make your life easy once you start coding. Good OO design will prevent you from making mistakes in fulfilling program requirements, and will reduce the size of your source code.
6) Make sure you have completed all of the assigned readings from your textbook (Reiss), and reviewed class notes (weeks 2, 3, and 4) before you attempt to start designing your OO program. Reiss gives a lot of useful hints and suggestions on how to produce good OO design. I strongly recommend that you follow class notes and your textbook as a guide for your OO design.
7) Spend plenty of time thinking about the OO Design before you attempt to write code!
8) Re-design and re-iterate until your OO Design becomes perfect in its simplicity, readability, and applicability for solving your programming problem.