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 patches' color yellow and asks turtles to draw some random lines. The second button simply runs the clear-all
primitive to clear everything.
xxxxxxxxxx
to make-drawing
ask patches [
set pcolor yellow
]
create-turtles 5 [
move-to one-of patches
pen-down
repeat 20 [
right random 90
forward 5
]
]
end
to clear-everything
clear-all
end
Once you mastered the ca
primitive, don't stop there. Check out the resources below to improve your NetLogo skills.
ca
primitive:clear-patches
Clears the patches by resetting all patch variables to their default initial values and making them black.
clear-turtles
Removes all the turtles as well as resets the numbering of turtles.
reset-ticks
Sets the tick counter to 0.