How to Correct Error: Can't Find Mean of List with no numbers
How to Correct Error: Can't Find Mean of List with no numbers
我正在尝试让海龟(觅食者)根据平均巢穴气味报告器移动,该报告器应该报告全世界巢穴气味传播的平均值,从巢穴的 200 到120在世界的相反角落。但是,在巢中,触发了以下错误,我不明白为什么。卑鄙的巢香不是一串数字吗?我该如何纠正这个错误?
Can't find the mean of a list with no numbers: [].
error while forager 7 running MEAN
called by procedure MEAN-NEST-SCENT-IN-CONE
to-report mean-nest-scent-in-cone [cone-distance angle angle-width ] ; ant procedure - reports the mean amount of nest-scent in cone
rt angle
let p patches in-cone cone-distance angle-width
;ask p [ show chemical ]
if p = nobody [report 0]
lt angle
report (mean [nest-scent] of p)
end
`````````````````````````````````
您将 'p' 设置为补丁集,但您正在测试它是否是 'nobody'。代理集的原语是 any?
。尝试替换:
if p = nobody [report 0]
lt angle
report (mean [nest-scent] of p)
和
ifelse any? p
[ lt angle
report mean [nest-scent] of p
]
[ report 0 ]
我正在尝试让海龟(觅食者)根据平均巢穴气味报告器移动,该报告器应该报告全世界巢穴气味传播的平均值,从巢穴的 200 到120在世界的相反角落。但是,在巢中,触发了以下错误,我不明白为什么。卑鄙的巢香不是一串数字吗?我该如何纠正这个错误?
Can't find the mean of a list with no numbers: [].
error while forager 7 running MEAN
called by procedure MEAN-NEST-SCENT-IN-CONE
to-report mean-nest-scent-in-cone [cone-distance angle angle-width ] ; ant procedure - reports the mean amount of nest-scent in cone
rt angle
let p patches in-cone cone-distance angle-width
;ask p [ show chemical ]
if p = nobody [report 0]
lt angle
report (mean [nest-scent] of p)
end
`````````````````````````````````
您将 'p' 设置为补丁集,但您正在测试它是否是 'nobody'。代理集的原语是 any?
。尝试替换:
if p = nobody [report 0]
lt angle
report (mean [nest-scent] of p)
和
ifelse any? p
[ lt angle
report mean [nest-scent] of p
]
[ report 0 ]