|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序8 J* Y" P; C/ J$ k+ {) {
其中有一段如下. ^* o9 F2 U; Y6 R# |# y
ask turtles with [ infected? = true ]
) H' x7 w: J+ u5 x我原本以为这句会回传『所有』infected? = true 的 turtle/ M- M) w7 Z' O9 J, D4 A) n
但看结果似乎不是这样。0 o6 ]6 H; }3 \, P& \+ E
& O, g, I8 w( j0 e1 W+ k! ^: D假设所有符合条件的有 5 笔3 y9 `4 q! o* T3 C0 F! q+ x
有时候回传 1 笔,有时回传 3 笔,是不固定的
% r+ y& u' n* H回头查语法定义
6 E4 b n9 @' }6 m$ Z+ L# g- l$ X2 ~with $ ]% ~' ?+ D5 o4 m0 F; y0 X$ C
agentset with [reporter]
9 u- h9 A: w) M* G. ~( yTakes 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) I! s7 R+ j2 Q+ f1 w
它只说回传 agents satisfying the given condition
+ b4 ~4 O1 E* X1 d3 z; ^' {8 C: c是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? : f7 U) ^1 `( r2 d2 i- c, a6 ?
+ d) b1 h M# u/ Q d
想确定一下
! i3 c, [7 ]) d谢谢!# ^4 @% f& M& P6 W, m6 {- _
|
|