Notes on Lab #9

For this lab, you will explore the Spreading of Fire Model using Matlab. In the process, you will learn a little about Matlab and software development.

Getting Started

To get started, download and unzip this file containing the general cellular automaton simulator, and this file containing functions specific to this lab. Copy the contents of the former (ca) into the latter (lab09). Then open the lab09 folder and double-click on the icon for the init file. This will launch Matlab and open the init file for you.

Your first task will be to modify this file (init.m) and the file update.m to get the spreading-of-fire CA working. To get started, do the following at the Matlab prompt:

    >> ca(20)

The cellular automaton program will pop up with a 20x20 grid and allow you to step it or run it at a chosen speed. Nothing interesting will happen, because you haven't completed the project yet: the functions are currently "stubs" that you will fill in. Note that once you've typed a command, you don't need to re-type it; you can retrieve it (and other previous commands) via the ↑ key in the lower-right area of the keyboard.

In the Matlab editor open init.m and underneath the XXX add some code to initialize the grid. You will find these slides useful for both this function and the update function. (Don't type; just copy-and-paste. Hit CTRL-A then CTRI-I periodically to make everything line up nicely.)

You should now be able to see an initial state that will not change when you step or run. To finish this part, add one or more lines of code in the appropriate places in update.m as well. To make your code a little easier to read, I have included some directional functions (north, south, east, west) that can replace the somewhat confusing calls to circshift in the update function.

Running the Simulation

Once you have the CA working, you should use it to do Project 1 a-c on p. 419. You'll want to do a longer run, using maybe 15 or 20 time steps instead of 5. The variables changeLightning and changeImmune are typos for chanceLightning and chanceImmune, which are really just the probLightning and probImmune already in the code. You can report your results qualitatively; i.e. a description of what happens in ordinary language, without numbers or graphs, but do mention what sized grid you used and how many steps you ran. If you have time, see whether you can do any of the other projects. When you're finished, rename your lab09 folder with your username (mine would by levys_lab09), put your PDF writeup in it, zip it, and copy it to the turnin folder.