如何在半径NetLogo内连接两个或多个海龟

时间:2015-06-10 16:36:47

标签: netlogo

我有更多的海龟在世界上移动,我想在它们在一个区域(圆圈)内时将它们连接起来。

这是一个例子:

enter image description here

我正在尝试使用这样的函数,在“go”过程中调用(勾选高级),但这不起作用。 有什么建议吗?

to connect
ask turtles in-radius radius [
  create-link-from myself
  create-link-to myself
]
end

1 个答案:

答案 0 :(得分:1)

如果我理解了你想要的东西,这将有效

globals [radius]

to setup
  clear-all
  create-turtles 50 [setxy random-xcor random-ycor]
  set radius 5
  connect
end

to connect
  ask turtles
  [ ask other turtles in-radius radius
    [ create-link-from myself
    ]
  ]
end

问题是您有ask turtles in-radius ...但未指定参考点。也就是说,在一定距离内是什么?在我的代码中,我要求每只乌龟成为参考点,然后要求距离自己的海龟进行连接。

相关问题