DOC PREVIEW
EVERGREEN INS 2008 - Modeling Line Patches

This preview shows page 1 out of 4 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 4 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 4 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

NetLogo Lab 3 Modeling Life With Patches Interacting Patches In previous two labs we have used turtles as mobile agents that move according to set rules and form spatial patterns. It is often the case that patterns and order emerges as a result of interactions that take place between stationary agents. Examples include growth of forests, the growth of algae, or the interactions between cells in an organism. In this workshop we will use NetLogo to model such interactions using patches. We will see that although the patches themselves do not move, waves of changes within the patches can mimic various types of complex movement. It is believed that such interactions are responsible for the complex patterns we see in animal coats, and perhaps at a more fundamental level for cell differentiation of a developing embryo. The Game of Life The mathematical concept behind the model we will build is that of a cellular automata. The fundamental idea is that each patch can have a number of different states and it changes states by examining the states of its neighbors and following some simple rules. We will start with the well-known example of Conway's Game of Life, and build from this to create a somewhat realistic model of the growth of stationary species. The model can be extended readily to include the sorts of chemical reactions that play a role in animal development. In the Game of Life, patches can have two states: alive and dead. The patches change their states according to the following rules: A patch that is dead will come to life in the next generation if it has three live neighbors. A patch that is alive will only continue to live if it has either two or three live neighbors. In this model we will let a patch that is alive have the state 1 and a patch that is dead have the state 0. Start your model by defining the state variable for the patches: patches-own [state] Then write a procedure called random-setup that randomly assigns either a 0 or a 1 to the state variable of each patch and then colors patches that have state 1 white and those with state 0 black. An efficient way of doing this is to random-setup clear-all ask patches [ set state random 2 set pcolor scale-color red state 0 1 ] end The line in which the pcolor is defined may seem funny (why are we using red when we want white and black?). scale-color returns a color value corresponding to a shade of the color specified, but black when the state variable is 0 and white when the state variable is 1. If the state variable was between 0 and 1 it would give a color which is a shade of red. There are certainly other ways of doing this, but this one will generalize naturally to the extensions you will do later.Rules of the Game Now it is time to apply the cellular automata rules for the Game of Life We will do this in a go procedure. The only thing this procedure needs to do is change the state of a patch according to the rules of the Game of Life. However, there is one subtlety you should be aware of. Since NetLogo executes commands to different patches sequentially if you are not careful one patch may change its state, before its neighbor has had a chance to ask it what state it was in. In order to keep all changes in step, we will first ask each patch to keep a record of the total number of its neighbors that are alive (state 1). Only once all of the patches have done this will we allow them to change state. The rule to change the state can be applied efficiently by using the an ifelse statement which allows you to execute different commands when different conditions apply. Nested if statements are used when more than two conditions apply to go ask patches [set total count neighbors with [state = 1]] ask patches [ ifelse total = 3 [set state 1] [if total != 2 [set state 0] ] set pcolor scale-color red state 0 1 ] end In order for the above code to be complete you need to add the variable total to the patches-own list. Notice the use of the neighbors primitive. This returns a list of the 8 patches surrounding the patch in question. Make sure you follow the logic of the if statement in this procedure. Later you may want to change the rules to create your own cellular automata. Create a button for the go procedure and test it. Designing Life After some initial craziness you should see the patches settle down to a few simple stable structures and perhaps a few blinking patterns. It may not appear too “life”-like but in fact there are a whole host of interesting “organisms” in the Game of Life, some of which appear to move (gliders), others which breed (breeders). If you run your game a few times you might see a few of these emerge. To see the more complicated “organisms” you need build them. There is no blind watchmaker in the Game of Life. Although it has been shown that it is theoretically possible to create self replicating “molecules” á la DNA, these are not stable to invasion by “parasites” and have no hope of evolving. However, we can be “watchmakers” by drawing “organisms” on a blank canvas. We can do this by using NetLogo's ability to track the location of the mouse. First create a clean-slate procedure that sets all the patches to be dead to clean-slate clear-all ask patches [ set state 0 set pcolor black ] end Now create a new procedure that will turn the patch at the location of the mouse to be alive(white and state 1) when the mouse is pressed. to draw if mouse-down? [ ask patch mouse-xcor mouse-ycor [ set state 1 set pcolor white ] ] end Since it is likely you will also want to erase mistakes, create a similar procedure called erase that you can use to “kill” a patch. The draw and erase procedures should be executed with “run forever” buttons. You may find it useful to put a command in your go procedure to stop if the mouse is down. Play around with this code for a while and see what life forms you can create. Try drawing the two patterns below. At this time you may want to try modifying the rules of the game in some way to see what other “lifescapes” you can create. Assignment: Extending the Model Although the “organisms” you created in the Game of Life may mimic biology, they are not a biological model per se. However, we can easily modify the code to model different situations in biology and chemistry. Here is what I propose, Let's allow


View Full Document

EVERGREEN INS 2008 - Modeling Line Patches

Download Modeling Line Patches
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Modeling Line Patches and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Modeling Line Patches 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?