NetLogo:如果 "at least one member of its network" 如何要求乌龟做某事

NetLogo: How to ask a turtle to do something if "at least one member of its network"

我想要求海龟在两种情况下做某事:1) 如果他们网络中的所有成员都显示出特定特征,2) 如果他们网络中至少有一个成员显示出特定特征。对于我尝试的第一种情况

                ask turtles [ if all? link-neighbors [audit?-last-tick = false] [
                set delta 0]

而且有效。 对于第二种情况,我尝试了

                ask turtles [ if any? link-neighbors [audit?-last-tick = true] [
                set delta 1]

                ask turtles [ if one-of link-neighbors [audit?-last-tick = true] [
                set delta 1]

但它不起作用。

你能帮帮我吗?

你需要with:

ask turtles [
  if any? link-neighbors with [ audit?-last-tick ] [
    set delta 1
  ]
]

请注意,您也可以使用 with 代替 if:

ask turtles with [ any? link-neighbors with [ audit?-last-tick ] ] [
  set delta 1
]

而且,除非你期望 audit?-last-tick 可能有一个非布尔值,否则你可以直接写 [ audit?-last-tick ] 而不是 [ audit?-last-tick = true ]