我遇到了 netlogo 的问题:我想在网络中传播信息。一只乌龟拥有信息并以恒定概率将其提供给它的链接邻居。这是我到目前为止的代码:
to spread
if (count turtles with [informed? = true] > .7 * count turtles) [stop]
ask turtles with [ informed? = true ]
[
ask link-neighbors
[
if (random-float 1 <= 0.02)
[
set informed? true
show-turtle
set color green
]
]
]
set num-informed count turtles with [informed? = true]
tick
end
现在我想知道:我怎样才能确保每只乌龟只获得一次信息而不会被告知两次?我试过“如果没有通知?”,但这只会让我收到错误消息。如果我希望以 2% 的恒定概率传播信息,我是否得到了命令“if (random-float 1 <= 0.02)”?