crt

 

create-turtles is a primitive that creates a given number of new turtles in the model. These new turtles are all placed at the center of the model with the same default shape but with random colors and headings. The shorthand version of this primitive is crt.

create-turtles 1015
crt 30

In addition, we can use the brackets () [ ]) to immediately give some rules to our new turtles. For example, the following code would not only create 100 new turtles but also make all of these turtles green and make each one go to a random patch. This way, we would not need to use a separate ask command.

create-turtles 100 [
    set color green
    move-to one-of patches
]

Things to keep in mind when using create-turtles:

In the model example below, we use the create-turtles primitive to create a landscape with a house, some plants, people, dogs, and clouds.

 

Try it Yourself

 
 
 
 
 
 
 

What's next?

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

 
Published NetLogo models that use the crt primitive:
 
 
Similar primitives:
hatch

Makes a turtle make any number of new turtles that are identical to itself.

Read more
sprout

Creates new turtles at the center of a patch.

Read more
ask

Asks agents to do things.

Read more
turtles-own

Declare a variable that belongs to turtles.

Read more
 
Learn another primitive: