In this assignment, you will code a simulation called "Game of Life". It is a very famous 'game' and the formed the basis of an entire field of simulation models called "cellular automata". Before continuing reading this assignment, I suggest you read a bit more about Game of Life at:
https://en.wikipedia.org/wiki/Conway's_Game_of_Life
or
http://www.math.com/students/wonders/life/life.html
(the latter also has a nice Java applet of the game that is quite fun to play with!)
You should now know about the basics of game of life: it is a 'simulation' of cells that are 'dead' or 'alive' in discrete time steps, at every step all of the cells will get computed a new value in parallel (i.e., based on the values of the neighbours at the *previous* time step - this will require a little bit of thinking!), and the rules to determine if a cell is dead or alive are:
You now need to write a program that reads in an initial 'board' configuration, and then performs a specified number of simulations.
As always, try and keep your program clean, modular, and only allocate as much memory as you need (using malloc).
The first line will specify 3 numbers:
The remainder of the input file comprises the initial configuration, which will have exactly the specified number of rows and columns. Dead cells are indicated with '.' while live cells are marked with 'X'.
As output, you will need to write the board configuration that results from the specified number of simulations, in exactly the same format as you read the input.
Sample Input
6 6 20
.X...X
X.X.X.
X...X.
X..XX.
..XX.X
...X.X
Sample Output
...X..
..X.X.
..X.X.
...X..
......
......