] ASK expected this input to be an agent or agentset, but got NOBODY instead. ASK 期望此输入是代理或代理集,但得到的却是 NOBODY。 当我们尝试访问不存在的代理时会发生此错误。这可能是因为代理人可能已经死亡,或者可能根本就不存在。 例如,以下代码会显示错误,因为我们的模型没有任何绿海龟: to setup...
if target != nobody [ ask target [ die ] ; 如果找到目标,target将死亡 set size size + 0.5 ; predator在捕猎后变大 ] end 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. ...
为了找到邻居最多的乌龟,可以遍历所有乌龟,比较并记录每个乌龟的邻居数量,最后找到邻居数量最多的乌龟。 以下是一个示例代码: 代码语言:txt 复制 to find-turtle-with-most-neighbors let max-neighbor-count 0 let turtle-with-most-neighbors nobody ask turtles [ let neighbor-count count neighbors if neighbor...
nobody如果未找到匹配的 VectorFeature,则报告。对于字符串,Value 比较不区分大小写,通配符“*”将匹配任何字符的任意次数(包括零次)。特征按照它们在作为数据集源的数据文件中出现的顺序进行搜索,一旦找到匹配项,搜索就会停止。对于数字,请注意有些数字太大而无法在 NetLogo 中表示为整数,因此如果您希望能够根据唯一...
turtle1.0 turtle number<breed> number Reports the turtle with the given who number, or nobody if there is no such turtle. For breeded turtles you may also use the single bree...linux学习笔记-01常用基本命令 查看命令 echo,echo命令用于在终端显示字符串或变量,格式为:echo [字符串 | 变量] ...
netlogo仿真代码示例(谣言传播)turtles-own[ id o influence tenacity trust] links-own[ w] globals[ tnum ] tosetup _clear-all-and-reset-ticks set-default-shapeturtles"circle" cro20[ setsize0.8 setcolorblue fd20 ] askturtles[ create-link-withone-ofotherturtles] ...
to find-turtle ask patches with [pcolor = red] [ let nearest-turtle min-one-of turtles in-radius 2 [distance myself] if nearest-turtle != nobody [ ask nearest-turtle [ set color blue ] ] ] end 上述代码首先选择红色的方块(patches),然后在半径为2的范围内找到最近的海龟(turtles),并将其...
if target = nobody [ set target one-of prey ] face target fd (speed ) ] end ``` 猎物代码: ```netlogo to escape[target] if target != nobody and prey-distance [target] < escape-distance [target] [ set health (health + escape-health) rt random-angle ] end ``` 注意事项: 在编...
问题就是while [not file-at-end?] [ let a file-read let b file-read ifelse c = a [ask turtle c [ create-link-with turtle b]] 读取的文件是形如 0 1 0 2 5 6 这种,不知道为什么里边的turtle b总是空的,报错为“CREATE-LINK-WITH expected input to be a turtle but got NOBODY ...
to spread-rumor ;; patch procedure let neighbor nobody ifelse eight-mode? [ set neighbor one-of neighbors ] [ set neighbor one-of neighbors4 ] ask neighbor [ set just-heard? true ] end 更新就是使得刚听到的变成不是刚听到,然后根据 hear-rumor 函数,更新 times-heard ,然 后通过 previous-...