|
| Csc 125 traditional - Computer Science II, Programming in C++ |
| Project 3 |
| Due: Tuesday, October 31, 2006 |
An environment to create "Game of Life" simulations.
In the October 1970 issue of Scientific
American, mathematician John Conway described a simulation that he called "The
Game of Life". It is a "cellular automaton" simulation that has become
very famous, and the basis of many variations over the years. In a very
complex form, SimCity and similar computer games are cellular automatons.
Cellular automatons also have many applications in scientific research.
A cellular automaton simulation consists of a grid of "cells", each with
specific characteristics, and a set of "rules" that govern how the cells react
to the cells around them. In John Conway's Game of Life, the rules are
applied to all cells at once, and then all cells are changed at the same time
according to the rules. The rules of his Game of Life do not include any
movement of the cells, they just react to the current state of the eight
immediately adjacent cells. An excellent explanation and program of John
Conway's Game of Life is at
http://www.math.com/students/wonders/life/life.html. You also get good
information at
http://en.wikipedia.org/wiki/Conway's_Game_of_Life.
You will be supplied with a working object oriented program that creates an environment in which you can create your own "Life" simulation. The engine in the supplied environment works a little differently from standard cellular automatons. Instead of applying the rules statically to all the cells in the grid, and then changing all the cells at the same time, the supplied program picks a cell at random and applies the rules immediately to the cell that was just picked. It simply repeats this action indefinitely, picking a random cell and applying the rules to that cell. This adds an element of randomness to the simulation. The same starting configuration will not necessarily result in the same action each time the simulation is run, as is the case with John Conway's Game of Life. Also, a cell now can move and interact with the other cells in more complex ways, including altering the other cells or even "killing" them and occupying their position in the grid.
Assignment
You must study and understand the given "Game of Life" code, and then use it to create a simulation of your own. The simulation must illustrate a concept, probably based on some ecological system. The concept must be significant and logical, and must be the basis of your simulation as you create it. You must not just create some behavior in two Lifeforms, and then just make up a concept or story that fits that behavior.
You must create at least two different types of "Lifeforms", which
interact with other "Lifeforms"
on the grid "Field" according to different rules for each type of
Lifeform. You are
encouraged, but not required, to have more than two types of Lifeforms.
Your program must run so that the result is interesting, non-trivial, and not
easily predictable. It must run for a reasonable amount of time,
progressing to some discernable trend or final state, illustrating the
underlying concept. Your simulation may have a fixed initial state coded
into the program, or an initial state read from a file. (An interactive initial
state read from the user's keyboard using cin will probably be
too slow, but if you can succeed in programming a reasonable interactive initial
state feel free to use it.)
Requirements
To implement at least two different types of "Lifeforms", you must create at least two derived classes from the supplied abstract base class Lifeform. These two classes must implement the specific rules of your simulation that apply to them in a virtual void DerivedLifeform::interact(Field&) method, that overrides the supplied base class virtual void Lifeform::interact(Field&) = 0 abstract method. The rules must be significantly different for each of the new classes. You may add any additional instance variables, constants, or methods to your derived classes needed to implement the rules. The rules for each derived class must be explicitly stated in the comments for DerivedLifeform::interact(Field&).
The rules must lead to a significant interaction between "beings" (i.e. objects) of your two different Lifeform classes. You will probably want to also program interaction between beings of the same class. The entire program must run to a conclusion that illustrates the concept of your Lifeform environment. The conclusion must not be essentially the same every time the program runs, but must have enough variation so that it illustrates a significant concept. Note, that a "conclusion" does not necessarily mean that the simulation stops running. If the Lifeforms reach a steady state, repeating essentially the same behavior again and again, then that could be considered the conclusion. The conclusion must not be essentially the same steady state every time the program is run.
Your program must create multiple
objects of at least one class.
You must also supply code that
initializes the Field to a starting state for the simulation, by creating
Lifeforms and putting them on the Field. This may be fixed code or code
governed by an initialization file that you supply.
Note that the supplied class Bacteria
is for illustration only. You must eliminate class Bacteria and its
related initialization code from your
final program, and then create at least two new Lifeform classes that are
significantly different from class Bacteria in their concept and interaction
with other Lifeforms. You will not be able to create objects of class
Lifeform directly, because it is designed as an abstract base class. Do
not change it into a concrete class by removing the "= 0" from "virtual void
interact(Field&) = 0;"
The supplied comments in the supplied code
describe the most likely changes you will want to make. In addition, you
may make reasonably small changes anywhere in the supplied code, as long as you
don't defeat the overall purpose of this project. If you would like to
make significant changes to the supplied code so that it runs significantly
differently, please check with the instructor first to make sure you are staying
within the educational purposes of this project.
Obviously the educational purpose of this project is to give you practice with Inheritance and Polymorphism by creating derived classes and overriding virtual functions in the derived classes. It will also give you practice with has-a or knows-a relationships, since you must create an additional "resource" class and objects of that class, to be used by the Lifeform objects. Your final program must implement these programming concepts explicitly in your additional code.
Your program should be written on a Linux or Unix system. It will be graded in my office on your Linux account.
Grading
Project 3 is worth 26 points toward the final grade. It will be graded according to the criteria on the Project 3 Grading Criteria.
Your project will be interactively graded on Halloween, Tuesday, October 31st. On Thursday, October 26th each student will sign up for a specific 15 minute period for grading on the following Tuesday. You may have your project graded before Halloween, if you wish, by making arrangements with the instructor.
| Back to Csc 125 - Computer Science II, Programming in C++ |
| Scott Badman Office: B132 Phone: 353-2250 sbadman@parkland.edu |
Parkland College, 2400 W. Bradley Avenue, Champaign, IL 61821 |