Miscellaneous

Resetting and starting over
+

Sometimes you just want to start over and work with a blank canvas. To do that type the following.

clear-all
Repeating Commands
+

Loops

ask turtles [ repeat 6 [ forward 5 ] ]
Tip: this does the same thing as [ ask turtles [ forward 30 ] ]
Selecting individual items (turtles, links, patches)
+

Sometimes you want to target a specific turtle or a group of patches, to do this we can use the following commands.

ask turtle 0 [ set shape "airplane" ]

ask link 0 1 [ set color brown]

ask patch 0 1 [ set pcolor orange ]

Advanced Turtles, Links, Patches Selection
+

Targeting a group of links

ask turtles with [color = red] [set color orange]

ask links with [color = red] [set color blue]

ask patches with [pxcor > 0] [ set pcolor yellow ]

ask turtles with [(xcor > 0) and (ycor > 0) and (pcolor = green)] [ set color brown ]

ask patches at-points [[1 0] [0 1] [-1 0] [0 -1]]