|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序% J s' }+ _/ ?. O2 q
其中有一段如下4 F$ k/ H) I- f" V; j9 H" S
ask turtles with [ infected? = true ]
/ b+ R& P/ t8 W G- r% ?5 j0 J我原本以为这句会回传『所有』infected? = true 的 turtle4 u/ x# Y, Z: s* h7 g
但看结果似乎不是这样。
2 J/ B1 e/ _% J3 D
' Y# K( R4 M8 ]% l假设所有符合条件的有 5 笔& D) k* Y$ q7 O* k, S+ B4 b
有时候回传 1 笔,有时回传 3 笔,是不固定的" ~! d5 u3 g5 k9 Q' M' K& X
回头查语法定义# s% c3 W6 g; m& T) E, O% V7 X
with - [/ V9 m2 h' M) Z' j) b
agentset with [reporter]
5 |8 ^) D7 _# g- g5 M& s* _Takes 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." S7 O2 B$ H9 }
它只说回传 agents satisfying the given condition) A/ R4 h% L( ^# w
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 9 |# u. p5 ~$ o, y9 u Z q/ S
5 K i5 Y- J. ]1 s, H: w想确定一下
! w: W4 l( v) ^, R谢谢!
$ H1 j) O9 ~5 T |
|