在 Netlogo 中,如何将乌龟移动到其 link 的另一端?

In Netlogo, how do you move a turtle to the other end of its link?

我在模拟中创建了两种海龟:一种是普通海龟,另一种是光环,旨在与每只海龟重叠。每当海龟被孵化(作为设置过程的一部分创建或使用 netlogo 的孵化功能创建)时,也会孵化一个光环并通过调用单独的 make-halo 函数 linked。

create turtles turtle-initial-number
;;(all the turtle genes are set here)
if halos-enabled [make-halo] 

to make-halo
  hatch-halos 1
  [ set size sight-radius * 2 + 1
    set shape "square"
    set color lput 64 extract-rgb color 
    __set-line-thickness 0.5
    create-link-from myself
    [ tie
      hide-link ] ]
end

由于我实施的一些互动,有时海龟和光环会彼此分离,所以我想在每个刻度的末尾添加一个步骤,所有光环会弹回到它们的海龟那里他们属于。有没有办法移动光环或将其坐标设置为link另一端的乌龟?

另一种选择是解决断开连接时发生的任何情况。我有另一种乌龟(人),他们可以 "push" 其他人使用下面的这个推开功能。占据人面前 9 个方格的海龟(及其光环)会沿着与人面对的相同方向向前推。当它们被推动时,由于某种原因,乌龟不再位于光环的中心。

to push-away  
  ask people [
    let push-dir heading
    ask patch-ahead 2 
    [ask turtles-here 
      [set heading push-dir
       fd 2]
    ask neighbors
      [ask turtles-here 
        [set heading push-dir
        fd 2]
        ] 
    ] 
  ]
end

理论上,tie应该是link的动作。但是要将光环捕捉到它的海龟,您可以 ask 光环到 move-to 海龟。唯一的技巧是识别正确的乌龟,而你没有显示足够的代码让我为你整理识别。

我建议您实际向记录他们的乌龟的光环添加一个变量,而不是使用 link。如果 link 没有其他用途,则无需创建所有这些额外的模型实体。你会像这样使用它:

halos-own [my-owner]

to make-halo
  hatch-halos 1
  [ set size sight-radius * 2 + 1
    set shape "square"
    set color lput 64 extract-rgb color 
    __set-line-thickness 0.5
    set my-owner myself      ; this is the new line
 ]
end

to push-away
  <all the code you have already>
  ask halos
  [ move-to my-owner
  ]
end