netlogo - Trouble using with-min -
a simple question, 1 i'm totally failing on.
i have group of turtles need locate nearest neighbour, wish create link between them. i've tried following code, keep coming null set [nobody found]:
ask turtles [create-links-with one-of other turtles with-min [distance myself]] can please point me in right direction.
regards
simon
there 2 problems here.
one create-links-with wrong because one-of returns single agent, not agentset. need create-link-with.
but main problem part:
other turtles with-min [...] netlogo understands other (turtles with-min [...]). reports empty agentset, because turtle wins with-min competition because distance zero, other eliminates turtle, leaving empty agentset.
instead, must write:
(other turtles) with-min [...] so both fixes together, get:
ask turtles [ create-link-with one-of (other turtles) with-min [distance myself] ] if want, can further shortened further using min-one-of instead of with-min, this:
ask turtles [ create-link-with min-one-of other turtles [distance myself] ] i made turtles , tried out in netlogo's command center, , got:

Comments
Post a Comment