我对原语"patch-right-ahead-ahead"有疑问.在模型设置中禁用世界包装时,我收到以下错误消息:
OF expected input to be a turtle agentset or patch agentset or turtle or patch but got NOBODY instead.
Run Code Online (Sandbox Code Playgroud)
当我做 :
if [pcolor] of patch-here = brown [
if [pcolor] of (patch-right-and-ahead 90 1) = brown [
move-to patch-right-and-ahead 90 1 ] ]
Run Code Online (Sandbox Code Playgroud)
在此先感谢您的帮助.
当通常返回代理的原语无法找到要返回的适当代理时,它将返回nobody
.在这里,没有补丁在当前代理的正前方(呃,因为角度是90,我猜对了).因此,它正在回归nobody
.您需要检查以确保它nobody
在使用之前没有of
:
if [pcolor] of patch-here = brown [
let target-patch patch-right-and-ahead 90 1
if target-patch != nobody and [pcolor] of target-patch = brown [
move-to target-patch
]
]
Run Code Online (Sandbox Code Playgroud)