为什么当我在 NetLogo 中取消世界环绕时会收到错误消息? [英] Why am I getting an error when I disengage world wrap in NetLogo?

查看:56
本文介绍了为什么当我在 NetLogo 中取消世界环绕时会收到错误消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我下载了一个工作模型,我正在调整它以符合我的标准.我想禁用世界换行,这样海龟的运动就被限制在初始屏幕上,但是当我这样做时,我收到一条错误消息,告诉我: OF 预期输入是海龟代理集或补丁代理集或海龟或补丁,但没有得到 NOBODY 代替.

I downloaded a working model and I'm adjusting it to fit criteria I have. I want to disable the world wrap so the turtles are constrained in their movement to the initial screen but when I do I get an error telling me: OF expected input to be a turtle agentset or patch agentset or turtle or patch but got NOBODY instead.

推荐答案

欢迎使用 StackOverflow!为了将来参考,您的问题有点不完整,因为其他人很难在没有看到您正在使用的代码的情况下帮助您.尝试包含足够的代码供其他人回答您的问题.我无法直接帮助解决您的问题,但我可以提供一些一般信息.

Welcome to StackOverflow! For future reference, your question is a bit incomplete as it's hard for others to help you without seeing the code you are using. Try to include enough code for others to answer your question. I cannot directly help resolve your issue, but I can provide some general information.

在 NetLogo 中,许多语言原语的行为在启用和不启用世界包装时都会发生变化.作为使用 patch-ahead 的示例,在双向包装的世界中,此代码将始终成功:

In NetLogo the behavior of many of the language primitives changes when world wrapping is enabled and when it is not. As an example using patch-ahead, in a world with wrapping in both directions, this code will always succeed:

; turtles will color themselves the color of the patch 1 unit away
ask turtles [
  set color ([pcolor] of patch-ahead 1)
]

但是如果在一个或两个方向上都禁用了换行,<当海龟前面没有补丁时,海龟的代码>补丁超前可以返回nobody,因为海龟在世界的边缘.在这种情况下,您要求 NetLogo 评估 [pcolor] of nobody,但这是不可能的,并且您会收到与您描述的类似的错误.

But if wrapping is disabled in one or both directions, the patch-ahead of a turtle can return nobody when there is no patch in front of the turtle because the turtle is at the edge of the world. In that case you are asking NetLogo to evaluate [pcolor] of nobody, but that is not possible, and you get an error like the one you described.

要解决此问题,您必须查看代码并查看这些错误发生的位置并进行适当处理.对于我的例子:

To resolve this issue you'll have to look through the code and see where these errors are made and handle them appropriately. For my example:

ask turtles [
  if patch-ahead 1 != nobody [
    set color ([pcolor] of patch-ahead 1)
  ]
]

您可以在文档中阅读有关NetLogo 模型的世界拓扑的更多信息.

You can read more about the world topology of NetLogo models in the docs.

这篇关于为什么当我在 NetLogo 中取消世界环绕时会收到错误消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆