face

 

face makes a turtle change its heading to point towards a specific patch or another turtle. For example, ask turtles [ face patch 0 0 ] turns all turtles in a model to face the center of the model.

In the model example below, we have a person and a butterfly. The person is trying to catch the butterfly, while the butterfly is trying to run away from the person. We use the face primitive to make the person turn to the butterfly at every tick before moving one step closer to the butterfly. We also use the face primitive to make the butterfly turn to the opposite direction by making it look at the person first and then turn 180 degrees (and add a bit of randomness to simulate the flight of the butterfly) at each tick before moving 1 step forward.

 

Try it Yourself

 
 
 
 
 
 
 

What's next?

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

 
Published NetLogo models that use the face primitive:
 
 
Similar primitives:
towards

Reports the angle of the caller towards an agent.

Read more
facexy

Changes a turtle's heading towards a specific point (x, y) in the world.

Read more
forward

Makes a turtle move in any number of units on a straight path.

Read more
right

Changes a turtle's heading a certain amount of degrees to the right.

Read more
 
Learn another primitive:
sort-on

Reports a sorted version of a provided agentset based on a user-defined comparison.

Read more
facexy

Changes a turtle's heading towards a specific point (x, y) in the world.

Read more
to

Begins a command procedure

Read more
of

Reports the value of an agent-owned variable.

Read more