|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序. @; G0 [& X2 M; M
其中有一段如下. n) m5 [7 l/ V8 W7 s
ask turtles with [ infected? = true ] ; {, p6 t$ u: E! P9 ]
我原本以为这句会回传『所有』infected? = true 的 turtle
, |; [0 C2 c" h0 x7 l m9 M但看结果似乎不是这样。
; l @9 I+ w/ ?9 e* c4 ^
( ^8 Q% }( K4 c2 D" ^假设所有符合条件的有 5 笔/ r7 k/ c; Z/ v* g6 ]
有时候回传 1 笔,有时回传 3 笔,是不固定的
! T) _* d" `; p/ i回头查语法定义; h1 |8 [2 }* {' ]( t4 z
with 9 ?( ^1 L3 n9 X/ G b: m; f& X
agentset with [reporter]
% V/ l a0 L' a0 X0 o/ [5 pTakes 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.
4 G: e+ ]) h6 F' X& e$ t- Y2 J" m它只说回传 agents satisfying the given condition
* l1 q+ Z3 S' J5 F& H是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 0 T8 b/ h8 b" W: r4 h% O
$ x* i- C1 ]& c/ W
想确定一下/ Y8 _3 y( Z# O( B9 x$ E: |4 m0 r
谢谢!
8 q: J2 J4 C, V2 S |
|