die

 

die is a primitive that we use to remove turtles and links from a model. When a turtle or link is asked to die, it no longer exists in the model, it will not execute any more code, and it will disappear from any agentset it was in. For example, the following model would have 9 turtles.

create-turtles 10
ask one-of turtles [ die ]

In the model example below, a flock of cows move around on a grassland. Every time they are on a green patch, they eat the grass there and gain energy. Every time they move, they lose some energy. If a grass ever has 0 energy, it dies and removes itself from the model.

 

Try it Yourself

 
 
 
 
 
 
 

What's next?

Once you mastered the die primitive, don't stop there. Check out the resources below to improve your NetLogo skills.

 
Published NetLogo models that use the die primitive:
 
 
Similar primitives:
turtles

Reports an agentset that contains all the turtles in a model.

Read more
links

Reports an agentset that contains all the links in a model.

Read more
patches

Reports an agentset that contains all the patches in a model.

Read more
create-turtles

Creates turtles with random colors and headings at the center of the world.

Read more
 
Learn another primitive: