Netlogo 如何在有红海龟的地方找到具有特定ID的补丁?
我对这段代码有问题Netlogo 如何在有红海龟的地方找到具有特定ID的补丁?,netlogo,Netlogo,我对这段代码有问题 ask persons [ set my-ID-polygon [ID-polygon] of patch-here [patch-here] of turtles with [color = red and shape = "x"] with [ID-polygon = my-ID-polygon] ] 我获得以下错误消息: TURTLES breed does not own variable MY-ID-POLYGON 事实上,我希望有一个ID为polygon=my
ask persons [
set my-ID-polygon [ID-polygon] of patch-here
[patch-here] of turtles with [color = red and shape = "x"] with [ID-polygon = my-ID-polygon] ]
我获得以下错误消息:
TURTLES breed does not own variable MY-ID-POLYGON
事实上,我希望有一个ID为polygon=my ID polygon的补丁,其中有一只颜色为红色,形状为x的海龟
提前感谢您的帮助。我想my ID polygon
是一个persons
变量,但在以下表达式中:
turtles with [color = red and shape = "x"] with [ID-polygon = my-ID-polygon]
第二个with
子句在turtles
的上下文中执行
也就是说,如果你想:
ID为polygon=my ID polygon的面片,其中有一只颜色为红色且形状为x的海龟
在NetLogo代码中,它转换为如下内容:
ask persons [
show one-of patches with [
ID-polygon = [ my-ID-polygon ] of myself and
any? (turtles-here with [ color = red and shape = "x" ])
]
]
我使用的情况下,许多补丁符合标准
with
子句在补丁的上下文中执行。为了获得询问者的my ID polygon
变量的值,您需要使用我的向上移动到外部上下文