Dark theme

Cellular Automata


In this practical we'll build a simple Cellular Automata (CA) model.


CAs are relatively simple to build and can be the foundation for very powerful models. In this practical we'll build the foundation for a small forrest fire model. In building a CA, the main things to think about are the boundary issues and artifacts of processing order. We'll look at these shortly.

First off, make yourself a new Python file called ca.py. Add the following variables at the top:

number_of_iterations = 10
width = 10
height = 10
fire_start_x = 4
fire_start_y = 4
fuel_amount = 5

Next, use the width and the height to make a 2D environment list containing the fuel_amount in each point. The algorithm is that we've seen a number of times for making 2D lists:

# Make a environment list
# Loop through range height
# Make a row list
# Loop though range width
# Append fuel_amount to row list
# Dedent out of inner loop
# Append row to environment list

Give it a go. Remember, as with all good code, think how you would test it.


  1. This page
  2. Building the environment <-- next
  3. Iterating
  4. Improving the model