Netlogo:我可以设置海龟之间的距离吗?

Netlogo: can I set the distance between turtles?

Netlogo:我可以设置海龟之间的距离吗?

您好, 我正在尝试创建一个模型,在该模型中,海龟在每次滴答时随机选择另一只海龟作为伙伴,并跳到与伙伴的指定距离(它给出的距离基于概率)。它移动到哪里并不重要,只要海龟相距指定的距离即可。 我试图通过创建一个“jump-with-probabilities”过程来对此建模,并在两个“IID”过程中定义乌龟跳跃的距离:

to jump-with-probabilities                 ;; adds behaviours depending on how a random number compares with the odds. 
   ask turtles [
   let random-fraction 
       random-float 1.0                            
   if-else random-fraction <= 0.4 
           [ IID_10 ] 
           [ IID_50 ] 
   ]
end


to IID_10                                
  ifelse distance partner  >= 10                  ;; if the distance to their partner is larger than or equal to 10
      [ jump (distance partner - 10) ]            ;; TRUE - jump forward by the difference of distance partner & 10, so that the distance is now 10
      [ jump (-1 * (10 - distance partner)) ]     ;; FALSE - jump backward by the difference of distance partner & 10, so that the distance is now 10
end


to IID_50                         
  ifelse distance partner  >= 50                   ;; if the distance to their partner is larger than or equal to 50
      [ jump (distance partner - 50) ]            ;; TRUE - jump forward by the difference of distance partner & 10, so that the distance is now 50
      [ jump (-1 * (50 - distance partner)) ]     ;; FALSE - jump backward by the difference of distance partner & 10, so that the distance is now 50
end

使用这个的问题是最后海龟之间的距离和我指定的距离不一样。例如,海龟 0 可能会跳向海龟 5,因此它们的距离为指定的 20。但是,海龟 5 也会跳向它的伙伴,这将改变海龟 0 和海龟 5 之间的距离。我考虑过使用“ask-concurrent”而不是问,但问题仍然存在,因为我告诉海龟移动一定的 距离 ,而不是移动到他们伙伴 的一定距离 [=25] =].

所以我的问题是;有没有办法告诉一只乌龟在另一只乌龟的指定距离内?这样如果伙伴移动乌龟也会移动以保持指定长度的距离。
我认为可以使用“移动到”并以某种方式添加指定的距离。或者,使用“距离”将其设置在 2 只海龟之间。这看起来很基础,但我一直无法弄清楚该怎么做!

如有任何帮助,我们将不胜感激!

可能有更好的方法,但我会通过将海龟 B 移动到海龟 A 所在的位置 (move-to turtleA),然后给它一个随机航向 (set heading random 360) 然后向前移动它来做到这一点10 (forward 10)。您也可以 hide 乌龟 B,直到您完成移动它,然后取消隐藏它以使可视化更整洁。那就是设置好相对位置,然后用Alan的建议tie来保持相对位置。