Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Netlogo 如何在有红海龟的地方找到具有特定ID的补丁?_Netlogo - Fatal编程技术网

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
变量的值,您需要使用我的
向上移动到外部上下文