我正在努力弄清楚如何告诉我的海龟向前移动一个空置的补丁,一旦它们已经被称为“转龟”的程序转过来。
let ahead patch-ahead 1
let vacant-ahead ahead with [not any? turtles-here ] ;;this line needs fixing
if any? turtles
[turn-turtle if vacant-ahead [fd 1]]
它产生了这个错误,我理解,但无法解决如何修复。
WITH expected input to be an agentset but got the patch (patch 1 -2) instead.
error while solute 2 running WITH
called by procedure MOVE-TURTLE
called by procedure GO
called by Button 'go'
以更易读的方式回复一些评论: 对不起我不认为我解释得很好,因为我刚刚拿出了一小部分代码。也许这更有意义。
to go
ask turtles
[move-turtle]
end
to move-turtle
turn-turtle
if (not any? turtles-on patch-ahead 1)
[fd 1]
end
所以我只是想让这段代码将已经被“转龟”转向的海龟移动到前面一个空的补丁1,最好占用整个补丁,就好像它们是“发芽的”一样。谢谢!
答案 0 :(得分:1)
如果你真的希望ahead
成为一个补丁,那么听起来你想要做一些不同的事情。也许
to move
ifelse (any? turtles-on patch-ahead 1) [
turn-turtle
][
fd 1
]
end