Question
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
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: -Any live cell with fewer than two live neighbours die, as if caused by under population. -Any live cell with two or three live neighbours lives on to the next generation. -Any live cell with more than three live neighbours dies, as if by overpopulation. -Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction. 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). Input The first line will specify 3 numbers: -the number of rows -the number of columns -the number of steps you need to simulate 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'. Output 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.. ...... ......
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started