Concepts to be applied for the problem:
- the use of one dimensional arrays
Problem description: In this problem you will have to create the "Game of life", originally created by
John Conway, The "Game of life" is a simple example of a cellular automaton. In the game of life you have a two dimensional environment made up of "cells", each cell is either alive or dead. For the purpose of this assignment the environment will be 10x12 in size. Cells interact with their eight neighbors, which are the cells that are directly horizontally, vertically, or diagonally adjacent. At each step in time, the following effects occur:
- Any live cell with fewer than two neighbors dies of loneliness.
- Any live cell with more than three neighbors dies of crowding.
- Any dead cell with exactly three neighbors comes to life.
- Any live cell with two or three neighbors lives, unchanged, to the next generation.
At the start of the program the user should be promoted for the number of alive cells to distribute randomly in the environment.
The user should also be ask for the number of steps to run the simulation for. Once this information has been entered the program should randomly distribute the specified cells in the initial environment and run through the given number of steps. At each step of the simulation the current environment should be outputted to the user, and a pause should occur until the user wants to continue onto the next step in the simulation.
Here is an external link for more information on the "Game of life", this link also has some nice movies of things you may see when running the program (Click here)
Here is some example output ( taken from the link above ): With the following initial setup in the environment:
You should get the following type of actions during the simulation:
|