|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
% v4 N3 Z, I& }9 B其中有一段如下% H& H" Q2 a" ] F7 z
ask turtles with [ infected? = true ] 0 C/ s9 Q! k, E) t: k1 e! f
我原本以为这句会回传『所有』infected? = true 的 turtle
8 k4 T, n: |0 W1 w, K但看结果似乎不是这样。; J( _0 W7 F; X8 H0 ^
7 s( ]( D( F1 u& |0 Y9 x# D' m' g假设所有符合条件的有 5 笔
! h' Y$ V8 h( k, m7 E/ S有时候回传 1 笔,有时回传 3 笔,是不固定的8 y' p# I, C9 R" H$ {/ n7 v' u
回头查语法定义7 M2 T( P' z& N& y
with
& A Q; F2 o- q% X A. L9 Oagentset with [reporter]
9 J2 L/ C8 y$ E' d5 S) I+ ?- oTakes 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.
! F, z/ }5 S6 q+ a" v' p+ \它只说回传 agents satisfying the given condition
4 V l/ P# O7 |# o4 m是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
0 N# U% ?) T! r0 W
5 A7 `* j4 F# F! f9 F; [想确定一下. j/ b ?, n& t& x( I5 @3 V
谢谢!
* y4 W+ u6 K0 l$ `9 c* k& q+ t( n |
|