当大多数智能体都有相同的变量值时,我试图停止我的模拟,但我真的不知道该怎么做。以下是我创建模型的代码和过程:
breed [birds bird]
birds-own [high]
to setup
create-turtles birds
[
set color blue
set shape "circle 2"
set xcor (-40 + random 25 )
set ycor (-40 + random 12)]
end
to go
ask birds
[
let Si4 [high] of one-of birds in-radius 1
let conc (( 4 * Si4) + ( 2 * Ai4 ) )
set high conc
]
end我尝试为操作使用不同的值来调整“高”变量,但当至少70-80%的鸟类种群具有相同的“高”值时,我需要停止模拟。我尝试使用命令“modes”和"max“,如下所示:
if max modes [high] of cells > 55 [stop] 但这会停止模拟,即使一只鸟有这个值,而不是大多数种群都有这个值,有什么建议可以正确地做到这一点吗?
发布于 2015-10-18 04:59:34
我会这样做:
let mode (modes [high] of turtles)
foreach mode [
if (count turtles with [high = ?] >= (count turtles * 0.7)) [stop]
]首先,我定义了列表mode,它是包含海龟自己的high中最常见元素的列表,然后针对每个列表,我检查具有该high的海龟的数量是否大于或等于海龟总数的70%。
如果列表mode的任何元素满足此条件,则停止模拟。
https://stackoverflow.com/questions/33190688
复制相似问题