4.7) Conditional Statements
Netlogo provides the usual range of commands for conditional statements. They are: if, ifelse, and while.
If statement: (if condition reports true, runs commands)
if condition [ commands ] if xcor > 0 [ set color blue ]
Ifelse statement: (reporter must report a boolean (true or false) value, if reporter reports true, runs commands 1, if reporter reports false, runs commands 2)
ifelse reporter [ commands1 ] [ commands2 ] ifelse pxcor > 0 [ set pcolor blue ] [ set pcolor red ]
While statement: (if reporter reports false, exit the loop, otherwise run commands and repeat)
while [reporter] [ commands ] while [any? other turtles-here] [ fd 1 ]