netlogo - 如何纠正错误:找不到没有数字的列表的平均值
问题描述
我试图让海龟(觅食者)根据平均巢香的报告者移动,该报告者应该报告世界各地巢香的平均值,从巢穴的 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 ]
推荐阅读
- amazon-web-services - 如何处理 Athena 中的一般内部错误
- php - preg_replace 与 preg_replace_callback
- mysql - grouping records by a field and submit a query on each group in sql
- python - 在 Windows 10 上安装外部库出错
- swift - 在 Swift 中使用 NSPredicate 的 Firebase Firestore 查询
- sql - 左连接与另一个查询以获得帖子的评论?
- python - django translation.activate() 接受什么语言格式?
- typescript - 尽管 while 循环使用变量,但没有未使用的变量错误
- android - Android Studio 无法添加图片或矢量资源
- python - 如何模拟 Moto 的 AccountId