|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序* _0 X# ~8 T% \3 n: O2 ]6 |2 U
其中有一段如下' T* z; n% V) ?, k3 K* G( h3 T
ask turtles with [ infected? = true ]
/ o: y( C# V4 z, Z, ]我原本以为这句会回传『所有』infected? = true 的 turtle& j! h4 L6 O) O* q
但看结果似乎不是这样。
+ w. \0 l! M) p) ]1 ~# w" d. S! T) z7 F2 V7 i( A1 f" z) f
假设所有符合条件的有 5 笔
8 b+ y( U9 t7 ?有时候回传 1 笔,有时回传 3 笔,是不固定的
^# i9 o, F K' ~/ r/ _回头查语法定义* W7 ~- X: k4 s# o9 o7 b
with
; J+ T* v: j4 @2 C3 U2 O( S% bagentset with [reporter]
- r( _, a, i6 I1 w WTakes 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.- `; o5 w/ L0 q4 @* x# ~5 N
它只说回传 agents satisfying the given condition
8 ]5 O5 t9 X$ D* }3 Q$ ^是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
7 @ X/ o% p4 h! j
# N8 r$ K! `- M- H; G( o2 K o想确定一下
0 q1 Q) X% z7 D, S+ g谢谢!
/ J4 X t8 H/ ]. E7 j, `6 B |
|