PROGRAM #3

Fall 2010

Due: October 29, 2010, 5pm on Angel


General Guidelines:


PROBLEM    A board game

For this assignment, you will be implementing a simple board game, as per the specifications stated below, using the best data structure of your choice.

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 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 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 (x,y) is/are left unaffected by this move.

Design:

It is expected that you use balanced binary search trees for this project. However, you are free to pick the STL container or containers as appropriate (set, map, multiset, multimap). But your choice should be based on what is expected to give the best performance (both time and memory) in practice. And your design is required to take the following assumptions into consideration:

i)                    In practice, you can expect n to be much smaller than m.  (For example, n=10, 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.

ii)                   You can assume that the number of players sharing the same x-value is going to be a small constant.

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


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