Moving turtles to agentset of patches

85 Views Asked by At

If I select an agentset of patches, for example:

<observer> let myset patches with [abs pxcor < (grid-size / 2) and abs pycor < (grid-size / 2)]
<observer> ask myset [print self]
(patch 1 -1)
(patch -1 -1)
(patch 0 0)
(patch 1 0)
(patch 0 1)
(patch 0 -1)
(patch 1 1)
(patch -1 1)
(patch -1 0)

How can I move all my turtles (Which are as much as my selected patches, so 9) each one to a DIFFERENT patch?

I tried the following:

ask turtles [
    move-to one-of myset 
    ]

But now it is possible that different turtles are on the same patch. How can I avoid this?

1

There are 1 best solutions below

1
JenB On BEST ANSWER

Assuming that there aren't any other turtles on the patches, then just get them to choose an empty patch (not sure the syntax is quite right, but something like):

ask turtles [
    move-to one-of myset with [not any? turtles-here]
    ]