|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序' U; r Z/ M+ }% @" K) l
其中有一段如下) t2 \4 i, n$ Y. K5 V; J9 B
ask turtles with [ infected? = true ] * G" r. }; |* {8 j6 f2 ~) p" E- K
我原本以为这句会回传『所有』infected? = true 的 turtle
9 q9 O* D' ]% k6 h6 ~ i但看结果似乎不是这样。, R! {) z3 c6 M+ p n+ Y- E8 W
, v( g8 J9 x! h# L1 B
假设所有符合条件的有 5 笔
1 ]: B/ J" K2 }. g% F" W1 a/ s有时候回传 1 笔,有时回传 3 笔,是不固定的7 L1 d8 {* x& C. m6 Z) q
回头查语法定义1 e* J# f' E, f$ S& s2 v+ n. Q
with
9 B5 B9 S7 K S+ _0 [: ]( Iagentset with [reporter]
* s- i1 O( w; x$ ^& 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.
( L; z. A" g2 \它只说回传 agents satisfying the given condition/ C v2 F2 I7 t1 ?! C
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
3 w* P/ H! _* B4 _) N! v$ k! @& ~. K6 ~, v
想确定一下. K5 M) N& _% Z, p% F" n9 j
谢谢!5 ]! F) e! O2 L8 A( V3 n- e9 t
|
|