|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
- x. @$ @* C6 U0 }) K7 u. V其中有一段如下
6 B* ~- ` l' W" V' i& r6 Oask turtles with [ infected? = true ]
8 ]7 P$ I% j4 i2 v" F9 E我原本以为这句会回传『所有』infected? = true 的 turtle
( E/ j/ ~0 m0 w8 L. H% X但看结果似乎不是这样。: n% C! h4 a5 a" M; C6 W' a
S0 ~! m* i2 D2 f, ^
假设所有符合条件的有 5 笔
9 V7 U8 O2 k, ~" }( n有时候回传 1 笔,有时回传 3 笔,是不固定的
% }0 @ I# _* o# j回头查语法定义
; l' i( w# q/ f0 l9 a' @3 E5 G! cwith
* p1 c3 ~, _! \. |7 ]agentset with [reporter]
0 m% l6 n4 \/ Q# z% a6 hTakes 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. ~+ `% I" F0 X9 Y; ]* D; @
它只说回传 agents satisfying the given condition
' c! c9 D- @" Y8 C: Z是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? I8 V- _" w; t4 v7 e. J
! n, P r1 e" F' p- D6 Y想确定一下
. Y2 I+ x; v( r4 m* ]1 I4 d) |谢谢!
. }$ k1 K( b- E7 d2 Z |
|