如何杀死网络中的选定链接

时间:2014-12-12 07:52:36

标签: netlogo

我正在尝试在Netlogo中创建一个命令,在那里我询问有关绿色的海龟的链接,而所有其他链接都会死亡,这样来往绿海龟的链接就会超过我的嘀嗒声重置。谁知道如何要求否定价值?就像'所有非绿海龟?我想不出来了!帮助PLZ。

2 个答案:

答案 0 :(得分:4)

可能有一个更优雅的解决方案,但这应该做你想要的:

询问[两端的[颜色]链接!=绿色] [die]

ask links with [ [color] of end1 != green OR [color] of end2 != green ] [ die ]

这假设链接的两端都需要连接到绿海龟。否则,您可以单独查看两端,并使用end1end2,如下所示:

ask links with [ [color] of end1 != green AND [color] of end2 != green ] [ die ]

答案 1 :(得分:3)

从乌龟的角度来看:

ask turtles with [ color != green ] [ ask my-links [ die ] ]

从链接角度来看:

ask links with [ [ color ] of both-ends != [green green] ] [ die ]

或者更高级,可能不太可读:

ask links with [ reduce or [ color != green ] of both-ends ] [ die ]