any? 2.0
any? agentset
Reports true if the given agentset is non-empty, false otherwise.
Equivalent to “count agentset > 0”, but more efficient (and arguably more readable).
if any? turtles with [color = red]
[ show "at least one turtle is red!" ]Note: nobody is not an agentset. You only get nobody back in situations where you were expecting a single agent, not a whole agentset. If any? gets nobody as input, an error results.