补丁如何显示海龟访问它的次数?

时间:2014-07-06 14:31:34

标签: netlogo

我想说明模拟后海龟访问过多少次补丁。

ask patches with [pcolor = lime] [ 
  if count turtles-here > 0 
    [set counter (counter + 1)]   
  set plabel counter
] 

看起来像那样。当乌龟访问它时,每个补丁的值都会增加。在模拟结束时,每个补丁将显示海龟访问它的次数。谢谢。

1 个答案:

答案 0 :(得分:3)

你的解决方案似乎很好。您只需要为counter属性提供补丁。例如,

patches-own [counter]

to setup
  ask n-of 50 patches [set pcolor lime sprout 1]
  ask patches [count-visits]
end

to go
  ask turtles [move-to one-of patches]
  ask patches [count-visits]
end

to count-visits  ;; patch proc
  if (pcolor = lime) [ 
    if count turtles-here > 0 [
      set counter (counter + 1)
    ]
  set plabel counter
  ] 
end