clear-all

 

clear-all essentially clears everything in a model: all drawings, turtles, plots, links, etc. It also sets the values of all the globals and agent properties to zero and makes all the patches black. It essentially reverts the model to a blank slate. You can also use ca as a shortened version.

clear-all is usually located at the beginning of a model’s setup procedure to make sure the model starts out with nothing already there.

In the model example below, we have two buttons. The first one makes the patches' color yellow and asks turtles to draw some random lines. The second button simply runs the clear-all primitive to clear everything.

 

Try it Yourself

 
 
 
 
 
 
 

What's next?

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

 
Published NetLogo models that use the clear-all primitive:
 
 
Similar primitives:
clear-patches

Clears the patches by resetting all patch variables to their default initial values and making them black.

Read more
clear-turtles

Removes all the turtles as well as resets the numbering of turtles.

Read more
die

Removes a turtle or link from the world.

Read more
reset-ticks

Sets the tick counter to 0.

Read more
 
Learn another primitive: