如何从没有海龟的代理集中选择补丁?



所以这是我觉得合理的代码:

let movable-patches ( [ neighbors ] of selected-turtle with [not (any? other turtles-here)])

我想得到selected-turtle相邻patchesagentset(这是一个turtle对象(,这些邻居不应该有turtles-here.

但是,它给了我一个运行时错误:

WITH expected input to be an agentset but got NOBODY instead.

这是一个括号问题。下面是演示固定代码的完整模型。

to testme
clear-all
create-turtles 10
[ setxy random-xcor random-ycor
set color blue
]
selection
end
to selection
let selected-turtle one-of turtles
ask selected-turtle [set color red]
let movable-patches ([ neighbors ] of selected-turtle) with [not (any? other turtles-here)]
ask movable-patches [ set pcolor red ]
end

我有这样的括号:([ neighbors ] of selected-turtle).你让他们围着[ neighbors ] of selected-turtle with [not (any? other turtles-here)].问题是with是一个高优先级运算符并且先行(就像乘法在加法之前完成一样(。因此,您实际上是在要求NetLogo找到selected-turtle with [not (any? other turtles-here)]然后neighbors

最新更新