如何移动到离海龟至少 x 距离的补丁

How to move to a patch that is at least x distance from a turtle

我想让一只乌龟移动到与另一只乌龟至少相距 x 距离的任何小块。所以在 NetLogo 和英语的混合中,它将是:

move-to one-of patches with [distance to nearest turtle > 4] 

请问如何实现?

您使用 min-one-of + [distance myself] 记者找到最近的乌龟。您还需要确保您只查看 other turtles,因为乌龟将始终是离自己最近的乌龟。

代码可以这样分解:

let nearest-turtle min-one-of other turtles [distance myself]
move-to one-of patches with [distance nearest-turtle > 4]

为了(可以说)更好的可读性。

编辑:感谢 Nicolas 的更正。你完全正确。

使用以上所有方法,这是一个解决方案:

to go
  ask patches [set nearest-turtle min-one-of turtles [distance myself]
    set distance-turtle distance nearest-turtle
    ]

  crt 1 [
    set color blue
    move-to one-of patches with [distance-turtle > 4]]

end