PROGRAM #3

Fall 2009

Due: October 30, 2009, 5pm on eLearning


General Guidelines:

Submissions are due by 5pm. A late penalty of 10% will be assessed for late submissions within the next 24-hour. Note: Submissions will be accepted only through the eLearning webmail. Any other submission outside the eLearning portal will be discarded and not graded. (In the unlikely event of an eLearning server outage on the day of submission, assisgnments can be emailed to the instructor's EECS email account.)


PROBLEM    A board game

For this assignment, you will be implementing a simple board game using the best data structure of your choice. A "board" is defined as a m x m square matrix, with each cell identified using a unique (x,y) coordinate. An example 10 x 10 board is shown in the figure below. In a game, a board has n players. It should always be true that n ≤ m. The figure shown below is for m=10 and n=8.

Your task is to implement the following specifications and functionalities:

Additional action is necessary if the destination cell (x,y) 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 a Boolean 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. 

You should make the best choice possible for the container data structure(s) based on what is expected to give you the best time and memory complexities in practice. In practice, you can expect n to be much smaller than m. You can also assume that the probability of O(n) players occupying cells with the same x-value is very low.

Design/coding complexity is another factor to consider although of secondary importance when compared to performance. 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.

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. State what data structure(s) options you considered, what you ended up using, why, what are the run-time complexities for each of the functions, and what is the memory complexity for your implementation as a whole. Figures and illustrations will be preferred.


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<YourLastNames>.zip