|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
% `, f- u) k4 C其中有一段如下) r I: W/ T( b. C
ask turtles with [ infected? = true ]
6 G0 L* @4 A" }我原本以为这句会回传『所有』infected? = true 的 turtle j: y7 t1 h6 s4 E9 d6 [8 b
但看结果似乎不是这样。, u% u0 {4 u3 m0 u, R, v2 {% Z- g
4 r- x0 `3 j0 b- h, E* V0 C( j6 [假设所有符合条件的有 5 笔
3 K7 F( J% O K! m有时候回传 1 笔,有时回传 3 笔,是不固定的3 Z" j6 S! }6 f% \. q
回头查语法定义
: @, i7 _0 y1 {- Q& xwith & [# G) S0 [+ p- }
agentset with [reporter]
' @. z5 n8 U# R2 v# y- o1 z! r1 a, LTakes 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.
& \3 {* t( @7 ?7 {. n它只说回传 agents satisfying the given condition' A& E: w( n1 Y/ |" Q
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
, v% X7 F- W0 A! L. I/ w! {* D& P! ]3 R
想确定一下# g* a7 w* O: h; u3 n: c
谢谢!
9 v4 L T7 l% V! [& _$ V5 {5 G |
|