如何让每只乌龟与其 link 邻居共享相同的 link

How to have each turtle share the same links as their link-neighbors

我一直在尝试编写一个模型,其中海龟与一定数量的其他海龟一起创建 links,并让这些海龟与 link 一起创建 links - link 的乌龟邻居。现在,我可以让海龟与其他海龟一起创建 link,但它们不共享相同的 link 邻居。我想以特定组大小的小海龟子组结束。然而,目前我只能告诉海龟创建一定数量的 links,但它们不会最终进入子组,因为它们的 link-neighbors 不一定共享相同的link-邻居。我想我可以让每只乌龟让它们的 link-neighbors 与我自己的 [link-neighbors] 一起创造-link-。我认为这会起作用,除了我收到一条错误消息,说乌龟不能 link 自身。我试图更改代码,因此它对乌龟说 link-neighbors [create-link-with [link-neighbors] of myself with [who != self] ],但这也不起作用。

这是我的一些代码:

;group size is 1 + (count link-neighbors) 
;preferred-size is a slider, used to alter what group size I want turtles to be in

 ask turtles 
   [if (preferred-size > group-size) and (any? other turtles in-radius 1 with [preferred-size > group-size])
   [create-link-with one-of other turtles in-radius 1 with [preferred-size > group-size] 

   ask link-neighbors
   [create-links-with [link-neighbors] of myself]
   ]

此外,是否有像 link-neighbors 这样的术语指的是一串连接上的所有海龟?

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

你们非常亲密!您只需要 other:

create-links-with other [ link-neighbors ] of myself

您无法将 whoself 进行比较:who 是一个数字,而 self 是一只乌龟。在 with [ who != self ]] 的上下文中,它们总是同一个海龟的变量。在任何情况下,通常最好避免处理 who 数字:几乎总是有更好的方法来做事。

is there a term like link-neighbors but referring to all the turtles on a string of connections?

我不完全确定这就是你的意思,但也许 nw:turtles-on-path-to? Or perhaps you will find some other useful thing in the nw extension