Search code examples
loopsforeachnetlogoagentagentset

Netlogo: How to iterate over agentset and set variable speed


I am attempting to iterate over a set of turtles and assign each of them a different, random speed. When I attempt to use:foreach turtles [ ... ] I get an error message stating "cannot iterate over agentset". I know I can use ask for setting all turtles the same, but I want to have turtles moving at different speeds from one another.


Solution

  • ask can do this job just fine:

    ask turtles [
      set speed random 10
    ]
    

    this will give each turtle its own different, random speed.