Programming Assignment 1: Game of Life
The objective of this programming assignment is to design and implement what is known as the “Game of Life”, conceptualized by the British mathematician John Horton Conway in 1970 to simulate the evolution patterns in a population of living organisms.
The game board is seeded with an initial population pattern, and then evolves based on the set of rules defining when a cell dies or is born into life. A cell’s life cycle depends on the state of its neighboring cells.
The game has no players - a user interacts with the “Game of Life” by creating an initial configuration and then observes how it unfolds. Some already known initial patterns have interesting predictable properties – you might discover a new one!
The implementation will only utilize the C++ programming concepts covered by pre-requisite courses. We will take an iterative approach; walk through the phases of specification, design and implementation.
Task #1 - Preparation
Please familiarize yourself with the topic by watching the following video:
https://www.youtube.com/watch?v=CgOcEZinQ2I (Links to an external site.)
Then read the description of the game – please note the rules of life, as this is what this assignment will attempt to implement:
https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life (Links to an external site.)
And here is an interactive demonstration – click the “next” button to watch how a pattern evolves. Your implementation will also need to display a new generation of the game board, but only using a simple character based (console) type of a display
http://www.bitstorm.org/gameoflife (Links to an external site.)
Task #2 - Specification
We will discuss the game specification in class. What functionality (encapsulated in the member functions/methods) will be needed to accomplish the goal? Which of those methods will be publically available (API) to invoke and operate the game, and which methods will be private to carry out the internal implementation details?
The specification will then be documented as part of the GameOfLife.h file – the comment section of the file, including the Pre-Conditions and Post-Conditions, followed by methods’ prototypes.
At the end of this part, the .h file will be fully defined, and it is expected that it will be implemented as such. Although many other implementations are possible, it is the requirement of this project to follow this model in order to meet the learning objectives.
Task #3 - Object Oriented Design
Object Oriented design asks to model all significant entities in a problem domain as classes, with appropriate structural relationships between them. We would then have two classes - one corresponding to the game itself (example: GameOfLife_T), and another one corresponding to a cell (example: Cell_T). The GameOfLife class will contain a private structure(s) of Cell_T. The entities will each have a set of responsibilities, reflected in the corresponding member functions/methods.
The GameOfLife_T would have to be able to:
Seed/initialize the game board with
a predefined pattern (from a file)
a randomly generated pattern (alive cells at randomly generated indexes)
Run the game
Execute the rules for every cell in order to generate the next generation of our cell population
Display the next generation matrix
Stop the game (ask a user up front how many generations to display, or ask a user whether to continue every step of the way)
The Cell_T would have to be able to:
Hold its state: value of the ‘state’ member set to true (indicates alive) or false (dead)
Communicate its state (whether it is alive or not)
Die (cell’s state set to false, and the face set to ‘dead’)
Come alive (cell’s state set to true, and the face set to ‘alive’)
Task #4 - Implementation
There are many ways to implement the generation of the “next step/generation” game board, and it will be up to a student to decide. We will discuss the options in class.
The display of the board will be character based, simply accomplished with console output.
--------------------
-----*--------------
----*-*-------------
--------*-----------
Please put your game in Namespace CSCI2312
Deliverables
A zip/archive file named <CSCI2312_PA1_LastName_FirstName.zip> containing:
h header file
cxx implementation file
cxx with main() to instantiate and run the game
txt – configuration file to seed the initial population pattern