我在 netlogo 工作已经有一段时间了,但有一件事我实在搞不明白。您可以询问乌龟它的出链接和入链接是什么,但是有没有办法使用两端和/或另一端的简单构造来询问链接的等效内容?
现在我的代码是
if one-of both-ends [firing = true] and one-of both-ends [time-not-fired = 1] [do-stuff]
但我想做的是
if my-in-turtle [firing = true] and my-out-turtle [time-not-fired = 1] [do-stuff]
是否有比使用 [fireing = true] 迭代所有海龟并询问其所有链接另一端是否有 [time-not-fired = 1] 更简单/更快的方法?
最佳答案
我认为您正在寻找
in-link-neighbors
它报告海龟集以及调用它的海龟的链接。
ask turtles with [firing]
[
ask in-link-neighbors with [time-not-fired = 1][do-stuff]
]
现在要小心这个代码,我要求一些海龟不止一次地做事情。因此要采取保护措施。
我意识到你想问的是链接而不是海龟。
“My-in-turtle”(源)被称为 end1
,“my-out-turtle”(目的地)在定向品种上被称为 end2
。
关于Netlogo:询问定向链接 "my-in-turtle"和 "my-out-turtle",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26758847/