PROGRAM #3
Fall 2012
Due: October 24, 2012, 11:59pm on Angel
General Guidelines:
· All source code must be in C++. You can use Windows or Unix environments at your discretion.
· Each program project should be accompanied by a COVER SHEET (see details below). Assignments without cover page will NOT be graded.
·
For this programming
assignment, you have the option of either work as a TEAM if you prefer, or as
an individual. A TEAM should contain at
most 2 students including yourself.
·
If working as a team,
submit only one copy of your assignment into the Drop box and indicate
in the text box of the drop-box while submission, both names in the
project. If you specify only one name then only that person will get the grade
and the other will not. So please make sure you fill in both names.
·
If working as a team,
remember to include both your last names in the zip file of your submission.
·
In the rest of this
document, the term “YOU” is used either to refer to you (if you are working
individually) or your team (if you work as a team).
· The final material for submission should be entirely written by you. If you decide to consult with others or refer materials online, you MUST give due credits to these sources (people, books, webpages, etc.) by listing them on the cover sheet mentioned below. Note that no points will be deducted for referencing these sources. However, your discussion/consultation should be limited to the initial design level. Sharing or even showing your source code/assignment verbiage to anyone else in the class, or direct reproduction of source code/verbiage from online resources, will all be considered plagiarism, and therefore will be awarded ZERO points and subject to the WSU Academic Dishonesty policy. (Reproducing from the Weiss textbook is an exception to this rule, and such reproduction is encouraged wherever possible.)
· Grading will be based on correctness, coding style, implementation efficiency, exception handling, source code documentation, and the written report. Try to also follow the good coding practices discussed in class during the C++ review lecture.
How to submit using Angel?
All assignments should be submitted to the PA3 Dropbox within Angel.
1) Once you login to Angel, click on the "Lessons" tab.
2) You will see "Programming Assignment #3".
Click on that and you will see the submission website.
Under Title, just write your first and last name and say PA 3 - e.g., "Ananth Kalyanaraman,
PA3".
If you are submitting as a team, only one of you
should submit, and put both your names on the Title:
e.g., "Firstname1 Lastname1 & Firstname2 Lastname2, PA3"
Leave the message textbox empty, unless you want to add a
special comment to us.
Then click on the "Attachments" button and attach your ZIP
file there. And then press the SUBMIT button
EMAIL
METHOD (backup only):
Only if dropbox doesn't work for
some reason, then you can submit by email to "All course faculty"
on Angel. Same time deadlines apply.
Late submission policy: A late penalty of 10% will be assessed for late submissions within the next 24-hour.
Any submission sent by any other means than specified above will be discarded and not graded.
PROBLEM A simple board game
For this assignment, you will be implementing a simple board game, as per the specifications stated below, using any (or more) of the data structures we have discussed in class so far (list, vector, balanced binary search trees (STL: set, map, multiset, multimap)) as appropriate.
Specifications:
A "board" is defined as a m * m square matrix, with each cell identified using a unique (x,y) coordinate. An example 10 * 10 board is shown in the figure below. In a game, a board has n players, where n ≤ m always. The figure shows an example for m=10 and n=8.
Your task is to implement the following specifications and functionalities:
Additional action is necessary if the destination cell (x2,y2) already has some other player, say Y. Then this function should first remove Y from the board before placing this player (ID) in its new position. Upon a successful move, the method should return true. If any player was removed in the process, the method should print a message to indicate which player was removed. If the move fails, the code should display an error message stating the reason of failure and return false.
Note: Any player(s) on the board along the path of moving from (x1,y1) to (x2,y2) is/are left unaffected by this move.
Design:
It is expected that you use balanced binary search trees for this project (STL set, map, multiset, multimap). You are also, in addition, free to pick other STL containers as appropriate. Your choice should be based on what is expected to give the “best” performance (both in terms of time and memory) assuming the following:
i) Although we will be testing for smaller values of n and m, your design should be optimized for the general use-case where the value of n is expected to be much smaller than the value of m. (For example, n=100, m=1,000,000). This simply implies that your code should not store the whole m*m board because it could run out of memory. Alternatively, think of storing only the occupied positions and the players.
ii) You can assume that the number of players sharing the same x-value is going to be a small constant.
iii) You can assume that for a given game, the value of m never changes. Of course the value of n could change dynamically as players are inserted and removed as the game progresses.
In trying to meet the above guidelines, you are permitted to maintain multiple data structures and/or copies of the same data in different containers as you deem necessary for design and efficiency. You are free to define new member functions not specified above to enhance code reuse and modularity.
Testing:
For testing, use the TestBoard.cpp code. This code is for the example board
shown above.
Save the output of your testing as a
text file and submit it as part of your report.
Written Report:
In a separate document (Word or PDF), compile the following sections:
· A: Problem statement. In a couple of sentences state the goal(s) of this exercise.
· C:Algorithm design (limit to 2 pages): Provide a design document for your code with the following information. State what data container(s) you used to support the different functions and why; what is the run-time complexity of each of the functions in your code; and what is the memory complexity for your implementation as a whole. Figures and illustrations can be used to show the design.
· D: Test results. Save the output of your testing using the TestBoard.cpp and attach it as a text file.
FINAL CHECKLIST FOR SUBMISSION:
___ Cover sheet
___ A separate folder containing all your sourcecode (including the main function you used for testing)
___ Report
___ Both the above zipped into another folder archivecalled Program3<YourLastName(s)>.zip
GRADING RUBRICS:
This assignment is mainly about designing efficient algorithms and implementations for the methods specified in the Board class. There is not really an extensive empirical component that involves timing and such but you need to pay attention to design in a manner that is expected to keep the runtimes really low for even large input cases. So for grading this PA, we will primarily look at how well you have designed your algorithm behind the implementation, how well you have implemented the code, and whether your code tests correctly. Therefore the points during grading will be distributed as follows:
The whole assignment is worth a total of 100 points.
----------------------------------------
ALGORITHM DESIGN, CODING & TESTING (75 pts):
(30 pts): Is the algorithm design efficient? That is, does the algorithm deploy the appropriate kind of data structures and use them effectively in a way that is expected to deliver the best possible performance both in terms of runtime and memory?
(20 pts): Is the code implemented in an efficient way? i.e., are there parts in the code that appear redundant, or implemented in ways that can be easily improved? Does the code conform to good coding practices of Objected Oriented programming?
(10 pts): Is the code documented well and generally easy to read (with helpful comments and pointers)?
(15 pts): Does the code compile and run successfully on a couple of test cases? Also does the output for the sample test case provided look right?
REPORT (40 pts):
(30 pts): Is the algorithm described well in the report? Are all important details effectively presented, or does the TA have to dig up some critical information (such as which STL classes were used to implement the Board class or how the MoveTo method was implementated using different data structures) from the code?
(10 pts): Is the basis of the choice of different data structures well justified/supported with the presentation of the expected time and memory complexities?
----------------------------------------
Obviously to come up with the above evaluation, the TAs are going to both read and run your code.