我希望移动与其他海龟有“安全距离”的海龟,例如一个补丁。 这是我的代码:
ask turtles [
let q neighbors with [
(not any? turtles-here) and (not any? other turtles-on neighbors)
]
if any? q [
face one-of q
move-to patch-ahead 1
]
]
if any? turtles-on neighbors [ ????? ]
开始条件是每只乌龟没有乌龟 - 邻居。 此外,我希望海龟找到一个新的补丁,如果乌龟在q或任何乌龟 - 在q邻居,但我不知道..
我也试着这个:
移动
ask turtles [
set ahead patches at-points [[2 1] [2 0] [2 -1]]
set neighbors-e patch-at 1 0
ask turtles with [not any? turtles-on ahead] [
let d distance exit ;exit is patch "target"
if (distance [exit] of neighbors-e < d) [
fd 1
]
]
]
端
但它显示错误:A patch can't access a turtle variable without specifying which turtle. (refer to neighbors-e)
这个想法是: