Reputation: 143
I have a set of turtles. each turtle have some neighbors, I would like to create a list of who numbers of neighbors, i.e., at the end I would like each turtles should own a list containing who numbers of neighbors. I tried it but some how one agent is always getting empty list of neighbors.
Upvotes: 1
Views: 422
Reputation: 14972
You can just use a combination of who
, of
, turtles-on
and neighbors
:
turtles-own [ who-of-neighbors ]
to setup
ca
ask patches with [ abs pxcor <= 1 and abs pycor <= 1 ] [ sprout 1 ]
ask turtles [ set who-of-neighbors [ who ] of turtles-on neighbors ]
ask turtles [ show who-of-neighbors ]
end
That being said, I don't know what your reason for wanting this is, but you should almost never use who
. It's pretty much always better to work with agentsets directly. You want to store the neighbors? Store turtles-on neighbors
directly.
Upvotes: 2