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

 
 
 
 
 
 
 

What's next?

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

 
Published NetLogo models that use the nobody primitive:
 
 
Similar primitives:
any?

Checks if there is at least one agent in an agentset.

Read more
member?

Reports true if a value is within a list or if an agent is in an agentset.

Read more
n-of

Reports "n" randomly picked agents from an agentset or items from a list.

Read more
let

Creates a local variable that only exists within a procedure or a statement surrounded with brackets (`[ ]`).

Read more
 
Learn another primitive: