netlogo - `is-agent?` 和 `is-turtle?` 之间的区别
问题描述
is-agent?
我相信这一定是一个简单的问题,但我还没有发现和原语之间的区别is-turtle?
,以及何时应该使用一个而不是另一个。
解决方案
海龟、补丁和链接都是代理。因此,is-agent?
将返回true
其中任何一个。但是补丁和链接显然不是海龟,所以is-turtle?
会返回false
这些。
breed [ ghouls ghoul ]
to test
clear-all
create-turtles 1
create-ghouls 1
ask turtle 0 [ create-link-to turtle 1 ]
show is-agent? turtle 0 ; true
show is-agent? ghoul 1 ; true
show is-agent? patch 0 0 ; true
show is-agent? link 0 1 ; true
show is-turtle? turtle 0 ; true
show is-turtle? ghoul 1 ; true
show is-turtle? patch 0 0 ; false
show is-turtle? link 0 1 ; false
show is-ghoul? turtle 0 ; false
show is-ghoul? turtle 1 ; true
end
因此,如果您试图将代理与数字、字符串和真/假值等内容区分开来,您可以使用is-agent?
. 当你真的,肯定想和海龟打交道时,使用is-turtle?
.
推荐阅读
- angular - 角度 6,带有 http Post 服务的嵌套参数
- spring - Thymeleaf 异常,试图将 .png 解析为模板
- linux - getuid/geteuid 奇怪的行为
- mysql - MySQL 假设部分 `pwrite()` 意味着磁盘已满
- javascript - 处理没有php的php数组
- swift - 从 Firebase 数据库中删除 - Swift
- gradle - swagger-codegen gradle 插件生成的构建(子)项目
- python - 快速将 xml 转换为 json xml(避免 CPU 使用 100 并减少 RunTime)
- jboss7.x - 引起:javax.persistence.PersistenceException:无效的persistence.xml。找不到元素“持久性”的声明
- symfony - Symfony3 - 重定向 301 https -> http -> https