0
votes

I have a simulation in netlogo in which there is a setup for turtles all around the world. The thing is when I create turtles, the go into random places. How can I make them fix ? note that I cannot specify xcor and yxor for every turtle as I have hundreds of them.

To setup-people
  tick
   set-default-shape people "person"
ask n-of 185 (patches with [pcolor = black]) [sprout-people 1]

  ask people[ set color cyan ]
  ask people [ set points 2 ]

reset-ticks
end
1

1 Answers

2
votes

One way to do this is with the with-local-randomness command.

breed [ people person ]
people-own [ points ]

To setup-people
  clear-all
  set-default-shape people "person"
  with-local-randomness [
    random-seed 0
    ask n-of 185 (patches with [pcolor = black]) [sprout-people 1]
  ]      
  ask people [ set color cyan ]
  ask people [ set points 2 ]
  reset-ticks
end

If you don't have a clear idea of what's happening here, I would strongly suggest reading the section on random numbers in the NetLogo programming guide.

The basic idea is that NetLogo will always use the same sequence of random numbers within the little block of local randomness, but it won't affect the rest of your model, so if you have other random behaviours, they will still vary from run to run.

That being said, how important is it that your people are always placed in the same location? Agent-based models usually have lots of random elements. If that makes you uncomfortable, it might be because you haven't fully taken stock of that yet. Just something to keep at the back of your mind as you move forward with your model design...

Note: I've replaced tick with clear-all at the top of your procedure, as I believe this is probably what you meant to write.