Netlogo从补丁3-3添加补丁的平均距离信息



我想知道如何设计它。

所有补丁都会将自己与补丁的距离[3-3]与平均距离进行比较。所以他们意识到他们离平均距离更近或更远。

globals [ref-patch av-dist]
to setup
  ca
  set av-dist mean [distance patch 3 -3] of patches
  demo
end
to demo
  ask patches [
    if distance patch 3 -3 < av-dist [
      set pcolor red
    ]
  ]
end

我想我会把所有东西都放在这样的补丁报告程序中:

to-report closer-than-average? report distance patch 3 -3 < mean [distance patch -3] of patches end

然后你可以

ask one-of patches [show closer-than-average?]

ask patches with [closer-than-average?] [set pcolor blue]

等等。

最新更新