Reputation: 47
I have questions regarding netlogo agentset operation looking for help, thx.
I want to add a patch, say patch-here, to a global agentset variable: mypatches. What is the correct way to write in a turtle procedure? I tried the following but it doesn't work:
set mypatches (patch-set mypatches patch-here)
I want to remove a patch, say patch-here, from a global agentset variable: mypatches. What is the correct way to write in a turtle procedure? The following code doesn't work because one-of operator assumes to remove self (which is a turtle) from mypatches but what I want is to remove patch-here from mypatches.
set mypatches one-of mypatches
Upvotes: 1
Views: 1774
Reputation: 7232
patch-set
expects a patch agentset, so you have to
initialize mypatches
to an empty set before adding first patches:
set mypatches no-patches
You can filter with with
:
set mypatches mypatches with [[patch-here] of myself != self]
Maybe more elegant and not so "self-confusing" solution is to ask a patch-here
to do it with other
:
ask patch-here [set mypatches other mypatches]
Upvotes: 1