The ; semicolon
is used for making helpful comments or notes on a line of code. All the characters will turn grey after a semicolon is used. Keep in mind that whenever a semicolon is used at the beginning of the line, this part of the code will not run. We can also place comments to the right of a line of code. For example:
; the procedure below moves the fish forward
to move-fish
ask fish [
right random 360 ; we make the fish turn randomly
forward 1
]
end
In the model example below, we use ; semicolon
to explain two lines of code and the wiggle procedure.
xxxxxxxxxx
; a line that starts with a semicolon (;) is a comment
; a commented line does not affect how the code runs
; but it helps us leave notes to ourselves
to setup
clear-all
ask patches [set pcolor 27] ; 25 is orange, 27 is light orange
create-turtles 1 [
set shape "butterfly"
]
create-turtles 1 [
set shape "tree"
set color green
set size 5
]
reset-ticks
end
to go
ask turtle 0 [ ; turtle 0 is the butterfly
wiggle
forward 0.5
]
tick
end
; to wiggle means to turn right or left randomly
; before every newn step
to wiggle
right random 90
left random 90
end
Once you mastered the semicolon
primitive, don't stop there. Check out the resources below to improve your NetLogo skills.
semicolon
primitive: