5.4. Exercises#
Game of Life#
Use your answer to Exercise 5.5 to create a Python notebook which simulates the Game of Life. The notebook should be well-organised with import statements, functions and executable code clearly separated.
Investigate how the long-term behaviour of the simulation depends on the initial conditions. Can you find initial states that result in the following?
All life eventually dying out
A pattern which eventually stays constant
A pattern which eventually repeats in a cyclic manner
A pattern which grows indefinitely
Use markdown cells to clearly explain your answers.
Diffusion Model#
Adapt your diffusion model code so that it stores the result in a 3d array z
. Each slice z[i,:,:]
should be an n
by n
array representing the concentration of the region at timestep i
.
N = 20 # number of time steps
n = 10 # size of region
z = np.zeros((N, n, n))
z[0,:,:] = # the inital concentrations
for i in range(N):
# set z[i,:,:] to the value of the next moving average
Then create line graphs which show the concentration at a point
1. At the centre
2. Near the edge
Over time. What is the long-term average concentration at each point?
Build a more realistic model of 2-dimensional diffusion. Assume that at each timestep a fraction \(d\) of the concentration in each cell leaks into each of the 8 surrounding cells. This happens in both directions, so that the value \(x_{i,j}\) in the next timestep is given by
Build a diffusion model based on the above. Experiment with different values of \(d\).