Netlogo:在补丁 属性 中存储代理集

Netlogo: Store agentset in patch property

我正在模拟一个街区。斑块代表住户,海龟人住在那里。 我想跟踪 "households" 并且认为在补丁中存储每个家庭的代理集会很方便。这样我就可以轻松 "household behavior",比如确保日常杂货。

然而,ask homePatch [ set houseHold (turtle-set partner myself) ]只是将0存储在补丁变量中。

是否可以在补丁变量中保存代理集?它在 patches-own 中定义。

补丁变量可以保存代理集,如下例所示。

patches-own [ household ]

to test
  clear-all
  ask patches [set household nobody]
  create-turtles 100 [
    fd random 10
    if any? other turtles-here [
      let partner one-of other turtles-here
      ask patch-here [set household (turtle-set partner myself)]
    ]
  ]
  ask patches with [household != nobody] [show household]
end

要了解为什么它似乎不适合您,我们需要查看您的更多代码,因为您提供的行确实有效。 (注意,如果"myself"的乌龟坐在homePatch上,可以直接用set household (turtle-set partner self)设置homePatch变量。