netlogo - 乌龟的父母死后如何追踪他们?
问题描述
在我的模型中,父母产生后代。以下是雌性产仔的程序,在这里,幼仔跟踪父母的身份。
to reproduce
if count mates > 0 [
hatch 3 [
set mother myself
set father one-of [mates] of mother
]]
可悲的是,他们的父母可能会死,所以mother
和father
变量变成了nobody
。有什么办法可以防止这些 ID 变成任何人吗?
解决方案
这是(非常罕见的)使用who
. 在您的情况下,我将为每个父母提供两个变量 - 一个您已经拥有,这样您就可以轻松地做出类似face mother
的声明,另一个存储who
您可以在父母去世后跟踪血统。您的代码将如下所示:
to reproduce
if count mates > 0 [
hatch 3 [
set mother myself
set motherID [who] of mother
set father one-of [mates] of mother
set fatherID [who] of father
]]
推荐阅读
- node.js - 弹性搜索索引数据未出现在 App Search 中
- php - 调用未定义的方法 App\Models\Comment::comments()
- python - 无法导入聊天机器人
- python - 管理前端上的 OneLogin 许可用户数与 API 不匹配
- api - Play 商店中的 API 支持
- java - 从 5.11.9 到 6.0.6 的 Hibernate Search 迁移 - 未应用分析器
- node.js - req.pipe(request()) / 管道将请求数据转入axios请求的axios等价物是什么
- wcf - 无法从 asp.net 核心连接的服务中读取 FaultException
- jetty - 嵌入式 Jetty 示例并使用 Micrometer 进行统计(无 Spring)
- python - 在 Jupyter Notebook 中导入 rioxarray 模块时出现问题