shape

 

shape is a turtle and link characteristic that represents the shape of an agent and allows us to change an agent's shape using the set primitive. New turtles and links are created with the default corresponding shapes. We can change an agent's shape using set shape “shape-name” format within an ask context. In addition, we can use shape as a reporter/variable to create conditionals etc. For example, if we wanted to create a model in which we wanted our turtles to look like either sheep or wolves and then make the wolves large, we would write the following code:

ask turtles [ 
    set shape one-of ["wolf" "sheep"]
    if shape = "wolf"[
        set size 1.5
    ]
] 

Things to keep in mind when using "shape":

In the model example below, there are sheep and wolves wandering around. Only the sheep eat the grass, not wolves, so we can distinguish between them by using shape to narrow down the agents who eat grass to only turtles with [ shape = "sheep" ] .

 

Try it Yourself

 
 
 
 
 
 
 

What's next?

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

 
Published NetLogo models that use the shape primitive:
 
 
Similar primitives:
color

Built-in turtle characteristic that reports the color of a turtle and allows us to change it.

Read more
turtles

Reports an agentset that contains all the turtles in a model.

Read more
set

Changes the value of a variable (global, local, or agent-owned).

Read more
of

Reports the value of an agent-owned variable.

Read more
 
Learn another primitive: