代理商互相分享他们的名单

agents sharing with each other their lists

我正在制作一个 NetLogo 模型。每个代理都有一个包含 5 个整数的列表(代理列表)。在每个滴答声中,海龟都会与另一只海龟创建 link,并彼此共享它们的列表。

turtles-own [ agent-list ]
.
.
.    
ask turtles [
    create-link-with one-of other turtles
    set agent-list lput agent-list of link-neighbors agent-list
  ]

我知道上面的代码不起作用,我该如何解决?

如您所述,组合列表的最简单方法可能是 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]