当我尝试确定将乌龟带到目的地的最近补丁时,会出现此错误。
this code can't be run by a patch
error while turtle 0 running DISTANCE
called by procedure GO
called by Button 'go'
这是有问题的代码:
let nearest-patch min-one-of patches in-cone 1 180 [distance dest]
if not any? other turtles-on nearest-patch
[ face nearest-patch
fd 1 ]
完整代码:
to go
reset-ticks
ask turtles
[
; going to the center, then goal
if dest = patch 0 0 and distance patch 0 0 < 3
[ repeat 5 [ fd 1 ]
set dest goal ]
; wrapping around and going to the center, then goal
if distance goal < 3
[ repeat 5 [ fd 1 ]
set dest patch 0 0 ]
face dest
let nearest-patch min-one-of patches in-cone 1 180 [distance dest]
if not any? other turtles-on nearest-patch
[ face nearest-patch
fd 1 ]
]
tick
end
帮助?