|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
7 P: j4 E0 k6 a* w6 F其中有一段如下& t |7 b) E" |) L1 b
ask turtles with [ infected? = true ] ' ^' _3 K3 a/ R; h" i' J! z6 x9 o
我原本以为这句会回传『所有』infected? = true 的 turtle
5 ]5 o0 T! l0 i" Q& v但看结果似乎不是这样。
$ K6 S- X4 Q* ? _0 x
2 `$ b! U' ]; u% V0 S( W/ V0 E假设所有符合条件的有 5 笔
" T! U! s* o2 ]* K3 J有时候回传 1 笔,有时回传 3 笔,是不固定的
# k8 e6 Y/ c( A2 p8 ^* W) ^回头查语法定义6 d! C- d( |1 u' Y
with ( `: Q; b' f& f, a, W! i
agentset with [reporter]
/ X/ g1 q& n R3 X% `2 f( ]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.
& {9 ^7 m/ M9 _; J7 A. L它只说回传 agents satisfying the given condition
n2 M1 u' {( t5 L$ J" p是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 2 D2 F* L6 k' o
* B' u" |6 |3 O0 [
想确定一下% o! Q$ L; i( O" o: c
谢谢!1 p0 b1 |/ ?6 @3 B
|
|