You are on page 1of 3

Alicia C.

MATLAB
UID: 304632470
CEE / MAE M20
August 8, 2017

Homework 6

1 The Game of Life


1.1 Introduction

The project aims to illustrate the living status of 150x200 bacteria for 300 generations by
following the rules indicated by the game of life. It assumes the presence of a single
bacterium in each grid in a 150 rows x 200 columns 2D array, where each bacterium is
either alive or dead initially at random.

1.2 Models and Methods

A 150x200 array is initiated using random real numbers ranging from 0 to 1 using rand
function. To enforce the condition that only around 10% of the bacteria are alive, we
check the 2D array grid-by-grid and change the value stored in each position to 1
(indicating the bacterium is alive) if and only if the random number is less than 0.1.
Otherwise, the value stored is changed to 0 to indicate death. We assume that the random
numbers given by rand function are uniformly probable.

For each timestep that represents a generation, we update the living status of the bacteria
one at a time, row-by-row starting from the leftmost corner using nested for loops. With
respect to each position in the array, the number of living bacteria in its 8 neighboring
grids are calculated. We use if-end statements to enforce periodic boundary conditions.
The bacterium in the current position of interest is alive if and only if it is surrounded by
2 or 3 living bacteria. Once the update is complete for a single generation, the image of
the living statuses of these bacteria are printed onto the screen. This process is repeated
for 300 generations.

1
1.3 Calculations and Results

20

40

60

80

100

120

140

20 40 60 80 100 120 140 160 180 200

An example of a static image of the bacteria at the end of 300 timesteps, where yellow
indicates living bacteria and blue otherwise.

1.4 Discussion

Between the first to the 300th timestep, the bacteria living status changes in a bubble-like
structure. However, some structures such as and do not change at all
throughout all 300 generations. The tiny squares scattering around and the
surroundings do not change either. While there are around 3000 bacteria alive initially,
the final number of living bacteria ranges from 35000 to 43000, depending on the random
numbers input. However, the final number of bacteria is consistently over 10 times more
than the initial number.

If the living condition is less strict, such that only 1 neighboring bacterium is required for
the bacterium of interest to live regardless of its initial status, the number of living
bacteria increases significantly as supported by the greater yellow areas in the following
example figure:

2
20

40

60

80

100

120

140

20 40 60 80 100 120 140 160 180 200

Should a stricter living condition be imposed, the final number of bacteria increases only
slightly, and the visualization produced does not show much changes. For example, if a
living bacterium live only if surrounded by 3 or 4 living bacteria, while a dead bacterium
is resurrected only if surrounded by 3 living bacteria, the following image is produced:

20

40

60

80

100

120

140

20 40 60 80 100 120 140 160 180 200

You might also like