nobody

 

nobody is a special primitive that we use to check whether an agent actually exists. In addition, when a turtle dies, it becomes nobody, too. For example, if we wanted to create a model in which each turtle formed a link with another turtle on a neighboring patch, we would write the following code:

ask turtles [
    let my-potential-friend one-of turtles-on neighbors
    if my-potential-friend != nobody [
        create-link-with my-potential-friend
    ]
]

Things to keep in mind when using nobody

In the model example below, we have a campfire in the middle, 10 tents, and 10 campers. When the go button is clicked, each camper moves around randomly. As long as an agent's my-tent variable is set to nobody, they keep moving around. In other words, the campers claim the tents randomly.

 

Try it Yourself