We’ll be simulating the fate of living cells using the rules from mathematician John Conway’s famous “Game of Life”. Cells exist at each point on a 2D grid and can be in one of two states: alive (1) or dead (0),
A randomly distributed matrix of 150 X 200 of values 1 and 0 is generated using the function
mat = randi([0 1],150,200);
For every time step the neighbour 8 neighbouring pixels are checked and the conditions of the next iteration are evaluated.
- A living cell with either 2 or 3 living neighbours survives on to the next generation.
- A living cell with fewer than 2 or more than 3 living neighbours does not survive on to the next generation due to isolation or overcrowding, respectively.
- A dead cell with exactly 3 live neighbours becomes a living cell in the next generation.
Thus we have evaluated the above conditions for 300-time steps and for every time step the output is shown using the imagesc function and every time step is generated using the drawnow function.
Initial Distribution Final Distribution
No. of Living Cells vs Time step
As observed after a certain time the pattern remains constant. No new cell is generated and no cell dies which can be observed from the graph plotted above that after a few time steps the no of living cells remains constant.
When I changed the criteria that a new cell is generated only if it has 4 living closest neighbouring cells it was observed that the graph of No. of living cells vs Time step showed similar results but now the no. of cells alive were more.
By changing the criteria as mentioned above