如何检测乌龟所在的补丁周围的邻居补丁的协调员(位置)?类似的东西:
patches with [(pcolor = red) and (any? turtles-on neighbors)]
或
[patch-here] of neighbors with [(pcolor = red)]
我想将乌龟移动到红色的邻居补丁。所以我需要先找到红色的邻居补丁。感谢。
答案 0 :(得分:3)
其中一个人可以在这里做你想做的事(http://ccl.northwestern.edu/netlogo/docs/dictionary.html#one-of)。像这样:
to move-turtle
let destination one-of neighbors with [ pcolor = red ]
if (destination != NOBODY) [
move-to destination
]
end
答案 1 :(得分:3)
要弄清楚你想要什么有点困难,但我认为你建议使用坐标而不是补丁。如果是这样,除非有充分的理由,否则不要这样做。在这种情况下,你可以
to move ;; turtle proc
let %candidates neighbors with [pcolor = red]
if (any? %candidates) [
move-to one-of %candidates
]
end