GEOG3150 - GIS, Geocomputation and Geoplanning - Semster 2


Table of Contents

1. Advanced Variables
2. Grass Grows...
3. Giving Birth.
4. Creating a graph.

Practical 3, part 3 - Giving Birth


Like the last section, this part is quite short. All that you need to do is add a few lines so that if the turtles have enough energy then they can give birth.

    Code to give birth
  1. Add the following code to the go procedure, after the turtle has decided whether or not a patch of grass is good to eat: if energy > 50 [
     set energy 10
     hatch 1
    ]
  2. That's it! The code above checks to see if the turtle has more than 50 units of energy stored up. If it does, then we reduce the amount of energy to 10 (to simulate the stress of giving birth) and then use the hatch command to create a copy of the turtle.

  3. Go back to the Interface tab and run the model. If you have it going slowly enough you might be able to see new turtles being born. Try experimenting with the grass-regrow-time slider. If you change the amount of time it takes for grass to re-grow, does this have an impact on the number of turtles in the model?

You'll probably notice that it is quite hard to work out how many turtles are actually in the model at any given time. It would be better if there was a way to see exactly how many turtles are alive at any given time. This is something that will be addressed next.


[School of Geography homepage] [Leeds University homepage]