【发布时间】:2021-08-28 23:27:47
【问题描述】:
我正在尝试将乌龟的局部变量与其邻居进行比较,并尝试找出符合此标准的邻居总数 total-nearby = 邻居总数。 我正在根据海龟的颜色进行检查,如果颜色不同,那么我将检查属性/变量 错误:如果不指定,补丁无法访问海龟或链接变量 哪个代理
代码:
turtle-own[
total-similar-nearby ; sum of previous two variables
total-other-nearby
total-nearby
native
language
income
maritalstatus
]
;;then assigning multiple number of turtles with different values to the local variables.
ask turtles[
repeat total-nearby
[
if color = [color] of one-of neighbors
[set d1 d1 + 1]
if color != [color] of one-of neighbors
[
if native = [ native ] of one-of neighbors
[set a 1]
if language = [ language ] of one-of neighbors
[set b 1]
if income = [ income ] of one-of neighbors
[set c 1]
if maritalstatus = [ maritalstatus ] of one-of neighbors
[set d 1]
] set p a + b + c + d
if p >= 50 [set d1 d1 + 1]
]
]
【问题讨论】:
-
Supratim,我看到你修改了你的帖子——但这并不是一个实质性的改变。您可以自己尝试一下:如果您创建一个全新的 NetLogo 文件,然后复制并粘贴您在此处编写的代码,您会得到什么?你得到一些无法编译的东西。您能与我们分享您的代码的工作示例吗?即,如果我们将它放在一个全新的 NetLogo 文件中,将显示您所询问的错误。
-
我想知道有没有办法,我可以将乌龟的局部变量与它的邻居进行比较?对于每只海龟,它会看它们是否有不同的颜色,然后它们会比较它们的属性
标签: netlogo neighbours