hatch

 

hatch is a primitive that creates a provided number of identical copies of a turtle. Similar to the create-turtles primitive, it takes a number and it also allows optional rules defined for the new turtles by following it with brackets [].

ask turtles [
    if season = "spring" [
        hatch 3 [
            set size 0.1
            set shape "penguin egg"
            set color white
        ]
    ]
]

Things to keep in mind when using hatch:

In the model example below, we have a turtle that represents a bug and some brown patches that represent food. When a bug bumps into a patch of food while walking around randomly, it eats the food and then hatches a new bug. Note that every time we create a new bug with the hatch primitive, we add the following command around brackets [ right random 360 ] because if we do not add this code, our new turtle would have the exact same location, size, and direction with its parent turtle, making it virtually impossible for us to differentiate the two.

 

Try it Yourself

 
 
0
 
 
 
 
 

What's next?

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

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

Creates new turtles at the center of a patch.

Read more
create-turtles

Creates turtles with random colors and headings at the center of the world.

Read more
die

Removes a turtle or link from the world.

Read more
ask

Asks agents to do things.

Read more
 
Learn another primitive:
tie

Turns a link between two turtles into a rigid connection so that the movement of one turtle impacts the movement of the other.

Read more
member?

Reports true if a value is within a list or if an agent is in an agentset.

Read more
reset-ticks

Sets the tick counter to 0.

Read more
patches

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

Read more