Abhishek Bhatia
Abhishek Bhatia

Reputation: 9796

Assign turtles random positions with no turtles at the same path in Netlogo?

How to do I assign turtles in Netlogo random positions at start, with no two turtles being assigned the same patch? Right now I use the following code but it doesn't give distinct patches for each turtle within limits.

 setxy ((random (lengthrec - 1) * 2) - (lengthrec - 1))  ((random (breadth - 2) * 2) - (breadth - 2))

Upvotes: 2

Views: 231

Answers (1)

Alan
Alan

Reputation: 9610

Assuming there is a global num-turtles and that this is smaller than the number of patches:

to create-turtles
  ask n-of num-turtles patches [sprout 1]
end

Upvotes: 3

Related Questions