|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序- E0 W& q, n6 Z: }. |: w0 I9 h) J
其中有一段如下
; Q- W1 {& u- M$ task turtles with [ infected? = true ] 6 I% X; J' G( E
我原本以为这句会回传『所有』infected? = true 的 turtle, [7 s; d+ }6 p1 Q
但看结果似乎不是这样。# ~4 D# I: Q% E- O
1 I; r5 j5 M) Z) |
假设所有符合条件的有 5 笔/ L( Q6 X/ P7 U, s. [
有时候回传 1 笔,有时回传 3 笔,是不固定的
* g u5 r8 ~& }2 l回头查语法定义; W2 a8 R8 {; g0 ?% M8 T% _6 h; y
with 2 u% M# ]+ H, _
agentset with [reporter]
7 T* k& Y( n3 J3 ]8 T3 H, ?& |Takes two inputs: on the left, an agentset (usually "turtles" or "patches"). On the right, a boolean reporter. Reports a new agentset containing only those agents that reported true -- in other words, the agents satisfying the given condition. I8 q) \( I# C* M$ ?9 s0 ]
它只说回传 agents satisfying the given condition3 v x6 B7 w* i, z
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? % r/ h% j; E: b: d, W, A3 R
+ ?+ g- f& X" p, O7 i5 Y
想确定一下
@1 k V* H8 Y# w) N: C, b谢谢!# }1 B1 k: p, _5 ?
|
|