in-radius

 

in-radius is a primitive that reports all the agents within a certain radius of the current agent. For example, a turtle might like to know how many other turtles are within a radius of two units of itself or a patch might like to know how many turtles are within three units of itself.

ask turtles [
    if any? other turtles in-radius 2 [
        create-link-with one-of other turtles in-radius 2
    ]
]

Things to keep in mind when using in-radius:

In the model example below, we have an environment represented with green patches and a factory at the center. When the go button is clicked, the factory pollutes all the patches within a radius of 5, represented by darker green patches.

 

Try it Yourself

 
 
 
 
 
 
 

What's next?

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

 
Published NetLogo models that use the in-radius primitive:
 
 
Similar primitives:
in-cone

Reports members of an agentset within a "cone-of-vision" of an agent.

Read more
other

Reports an agentset which is the same as the input agentset but omits the agent that used this primitive.

Read more
neighbors

Reports an agentset containing the eight neighboring patches.

Read more
with

Reports a subset of the original agentset that only contains the agents with specified characteristics.

Read more
 
Learn another primitive: