|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序1 Z5 ?: p0 d$ S5 s7 X9 ^" t
其中有一段如下( T2 L$ C+ g( ^0 C9 ~
ask turtles with [ infected? = true ] 7 e, d4 H; P* o5 A. G( u5 f
我原本以为这句会回传『所有』infected? = true 的 turtle
' v2 N. v7 q1 K5 `7 X: x但看结果似乎不是这样。9 Z6 ?0 o/ Y# v+ i. x4 M
. Q& F% \5 k, n- ^, H! }! C假设所有符合条件的有 5 笔
" ]0 @2 [6 ^( I9 v有时候回传 1 笔,有时回传 3 笔,是不固定的8 K) }6 X8 h: y2 G& O9 _1 p Y; P
回头查语法定义3 G0 N7 g0 L6 u' K$ ?
with
/ r3 e! ^: k9 i2 p# sagentset with [reporter]
( h6 I+ Q% {/ n4 i+ 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.
2 \0 h* d: ]6 \! r" {' r) [# H% ]它只说回传 agents satisfying the given condition
: @% o3 v# } ^" r- M# b是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
* V8 |6 Z$ b9 ^- }) J( h1 k' w2 I) a! ]$ t! i( y. K
想确定一下/ U+ z1 S4 O" a! w% u! ~5 b
谢谢!( q# \: W: _$ c; H9 R
|
|