in-cone

 

in-cone is a primitive that helps us simulate a "cone of vision" in front of a turtle. It allows us to model an agent having some sight or other sense in front of them, but not behind or to the side of them.

The cone is constructed with two inputs: how far the agent can see (radius), and how wide the agent can see (degrees between 0 to 360). For example, if we wanted some rabbits to eat if there were carrots in front of them, but not behind or to the side, we could write the following code:

ask rabbits [
  if any? carrots in-cone 3 45 [ eat ]
]

Things to keep in mind when using in-cone:

In the model example below, we use in-cone to simulate four motion-activated wildlife cameras. When a camera detects that there are any? animals in-cone 8 50, it will turn yellow to simulate taking a picture. (Note that the highlighted patches are just to better visually show the cone of vision. In actuality none of the in-cone turtle detection has anything to do with which patch a turtle is standing on.)

 

Try it Yourself

 
 
 
 
 
 
 

What's next?

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

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

Reports members of an agentset within a certain radius 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: