Class Photo | Course Home | Homework | Programming | Schedule & Lecture Notes | Submit

Saint Louis University

Computer Science 220
Computer Science II
Michael Goldwasser

Fall 2004

Dept. of Math & Computer Science

Programming Assignment 03
Survivor

Due:
Part 1 - Wednesday, 6 October 2004, 8pm
Part 2 - Monday, 11 October 2004, 8pm
Monday, 18 October 2004, 9am

Please make sure you adhere to the policies on academic integrity.

Please see the general programming webpage for details about the programming environment for this course, guidelines for programming style, and details on electronic submission of assignments.

The files you may need for this assignment can be downloaded here.


Contents:


Overview

Apparently, you cannot run a network these days without the typical "reality" show (e.g., "Survivor," "Big Brother," "The Bachelor," "The Apprentice," ad nauseum). Each of these invovles the basic premise of starting with a group of people, and one-by-one removing people until only one remains. This, combined with a million dollars and some clever marketing appears to be a formula for success.

In this assignment, we are going to make a program which can be used for modeling these games and deciding whom to remove at each stage. Specifically, we will use a classic children's method for selecting a person out of a group. The people are arranged in a circle, and then someone starts pointing to the people one by one around the circle, while chanting the phrase

"Eeny-meeny-miney-moe, catch a tiger by the toe, if he hollers let him go, eeny-meeny-miney-moe. My mother told me to pick the very best one and you are not it."
Whomever is identified when the last word of the phrase is completed is eliminated from the game (and thus never counted again). The phrase is restarted with the neighbor of that person most recently eliminated, and again a second person is removed based on the end of the phrase. A third and fourth player are removed in this way, continuing until there is only one person remaining. That person is the survivor!


Modeling the Game

The main parameters in modeling the game are the number of original people in the group, and the number of syllables used in the phrase for removing people. In this assignment, we will let N denote the number of players in the game and K denote the number of consectutive steps which are taken around the circle before the elimination of a player. Once a person has been removed from the group, they should never be counted again when counting steps.

For consistency, you should refer to the original players as if they are numbered from {0, ..., N-1}. Also, please start the game so that the first step is at Player 0. As a simple example, if we play the game with N=5 and K=3, players would be removed in the following order:

Player 2 is removed.
Player 0 is removed.
Player 4 is removed.
Player 1 is removed.
Player 3 has survived!
Please simulate the above example by hand. If you do not get exactly the same result as shown then you are misinterpreting the conventions for this assignment.


Your Task

For this assignment, you will be required to give two different implementations for simulating an abstract class game:

The precise details of the required classes are outlined. in the following section.


Files We Are Providing

All such files can be downloaded here.


Experiments

When the completeGame command is executed through our driver, it reports the amount of running time which was spent during the call to your routine. We would like you to use this in order to run some experiments regarding the relative efficiency of the two implementations.

For evaluating running time, always test your program with verbose set to false. Output to the screen would signficantly skew the measurements of the underlying efficiency of your methods.

Your readme file for this assignment should include two tables, one for each implementation, reporting the running times for each of the following cases:


Files to Submit


Two-part Deadline

You will notice that we have listed two distinct deadlines for this assignment. The completed ArrayGame implementation must be submited by the first of the two deadlines (it will be considered late if it is submitted or modified after this point in time).

By the second deadline, you must submit your LinkedGame implemenations as well as the required test and readme files.


Testing Your Program

One good test is to make sure that both implementations actually give the same output when run with identical parameters. Secondly, you should certainly test your programs versus the example given earlier in this assignment. If you would like a few more answers to compare to, here is the survivor for several other cases:


Grading Standards

The assignment is worth 10 points.


Extra Credit (2 points)

Chances are, though you may feel that your code is already complete and works properly, it may be that it has an inherent memory leak which is going unnoticed! Since I expect that your ArrayGame and LinkedGame classes will both involve the allocation of memory to represent a game, you must remember the lessons of Chapter 1.5.3 of the text.

For extra credit, redefine both your array and linked classes so that there exists an appropriate destructor, copy constructor, and overloaded assignment operator. Please note that the initial files we provided to get you started are incomplete, and do not contain the necessary definitions for these tasks.

To test the correctness of your extra credit implementations, you should create a new game, play some of the rounds but not all of the rounds, then invoke the "X" option in the menu-driven driver. This command begins a series of steps to clone the current game, presumably making a brand new game which has identical state as the original game. Then it intentionally destroys the original game and uses the clone as the current game from this point on. If you've done your extra credit tasks correctly, you should be able to comlete the current game at this point and it will look just like you are completing the original game.

For example, run the driver with the following input,

L
5
3
V
P
P
X
C
and you should see verbose results similar to the example given earlier in this assignment.

You can receive 1 point for correctly adding this functionality to your ArrayGame class, and 1 point for the LinkedGame class.


CSA-220, Fall 2004
Michael Goldwasser
goldwamh at our university domain.

Last modified: Sunday, 13 February 2005
Class Photo | Course Home | Homework | Programming | Schedule & Lecture Notes | Submit