|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序8 v+ D' ]+ b$ D6 ~, J! K
其中有一段如下
4 W+ n2 p7 f: bask turtles with [ infected? = true ]
( ?. C6 j0 C4 i F7 q% B5 E3 K: a& R我原本以为这句会回传『所有』infected? = true 的 turtle2 E& }+ I7 w4 N) ]
但看结果似乎不是这样。
+ m* n k- D- a# {$ ~1 c' ]& F+ P0 ]0 ?0 F) {. {
假设所有符合条件的有 5 笔
' t" ^2 Q% \6 _有时候回传 1 笔,有时回传 3 笔,是不固定的5 ]9 i' n+ |, V
回头查语法定义: j* {& c7 C" P( o( K4 X8 |5 z( t
with
1 V; Z/ n% U2 \9 {- Q. ~# ?' |agentset with [reporter]- X4 j9 g1 x! G
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.
p" v, f: ]4 }. m5 v7 T9 l7 z它只说回传 agents satisfying the given condition
) m; q G- ^9 J0 @) C8 X1 g是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
( d! V1 u6 G& t. t, e* x, J1 `: [7 T! n' g" m, \
想确定一下
. G2 [& o" g' K谢谢!" R' r. ^; `6 m1 c; T" p
|
|