Reputation: 25
In my setup, I am using the following code to create agents called "darks", and these agents are assigned to a designated set of patches (free-patches).
I am trying to have each turtle assigned to a random patch within the designated area without any of the turtles sharing a patch.
I have stumbled across code that tells a patch to sprout a specific turtle, but can I accomplish my goal without resorting to the patch sprout?
create-darks #-of-darks [
set shape "person"
set size 1
set color black
move-to one-of free-patches
]
Upvotes: 1
Views: 1558
Reputation: 3806
You can just get a patch with no darks there.I would also only create a dark if there's enough space.
let n-or-remaining-spaces min (list n (count patches with [not any? darks-here]))
create-darks n-or-remaining-spaces
[
;;Your other setup code
move-to one-of patches with [not any? darks-here]
]
Upvotes: 2