我正在制作NetLogo模型。每个代理都有一个由5个整数组成的列表(agent-list)。在每个刻度上,海龟都与另一只海龟建立链接,并彼此共享其列表。
turtles-own [ agent-list ]
.
.
.
ask turtles [
create-link-with one-of other turtles
set agent-list lput agent-list of link-neighbors agent-list
]
我知道上面的代码不起作用,应该如何解决?
答案 0 :(得分:1)
最简单的组合列表的方法可能是sentence
:
turtles-own [ agent-list ]
to setup
ca
crt 3 [
set agent-list map [random 10] range 5
]
reset-ticks
end
to link-and-share
ask turtles [
let target one-of other turtles
create-link-with target
set agent-list sentence agent-list [agent-list] of target
show agent-list
]
end
但是,您将根据自己的实际情况进行一些调整,因为这意味着以后在过程中链接的海龟很可能会拉agent-list
只已经修改了它们的海龟拥有agent-list
。因此,如果乌龟0抓住乌龟1的agent-list
,那么以后乌龟4抓住乌龟0的agent-list
,则乌龟4的agent-list
由15个整数组成,而不是10,类似于输出如下:
(turtle 1): [6 1 5 4 7 3 9 8 1 1]
(turtle 0): [9 0 3 3 5 3 9 8 1 1]
(turtle 2): [3 9 8 1 1 9 0 3 3 5 3 9 8 1 1]