【发布时间】:2022-01-01 05:39:39
【问题描述】:
我可以使用下面的代码绘制每只动物的蠕虫总数(在 图 1 中可视化)。
plot sum [worm-number] of animals
我希望我的图表像 图 2 那样是累积的,但我不知道如何编码。 Previous examples 使用在 NetLogo 6.2.0 中不起作用的旧语法,并且不显示如何绘制数据。
【问题讨论】:
标签: simulation netlogo agent-based-modeling
我可以使用下面的代码绘制每只动物的蠕虫总数(在 图 1 中可视化)。
plot sum [worm-number] of animals
我希望我的图表像 图 2 那样是累积的,但我不知道如何编码。 Previous examples 使用在 NetLogo 6.2.0 中不起作用的旧语法,并且不显示如何绘制数据。
【问题讨论】:
标签: simulation netlogo agent-based-modeling
您只需要使用一个全局变量来跟踪新蠕虫,并参考该变量进行绘图。
由于我们没有您的代码的完整示例,因此我将编写一些似是而非地模仿您应该做的事情:
breed [animals animal]
globals [
cumulative-worms
]
; **************************
; The rest of your code here
; **************************
to get-infected ; The procedure executed by animals when they get new worms.
let new-worms (1 + random 5)
set worm-number (worm-number + new-worms)
set cumulative-worms (cumulative-worms + new-worms)
end
此时您可以创建一个将使用plot cumulative-worms 的绘图。
【讨论】: