Turtles should die of old age, how do I make a turtle live for only a certain number of steps? How can I give my agents a life span?
We can use an agent variable to count the number of steps an agent has taken. When that number exceeds some limit the agent can die. One thing to note when creating the agent through a hatch block as in the emitter code here. Hatch will make a clone of the current agent -- it is important to initialize (that is set the initial value) of the age variable so that it doesn't inherit the age of the turtle that it was cloned from.
Submitted by joshua on 8. February 2008 - 17:50