|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序& G( q* I) f: D0 O
其中有一段如下3 U+ ]8 L R& }2 h: V
ask turtles with [ infected? = true ] 8 h; @0 x/ ~9 h+ C3 f5 C
我原本以为这句会回传『所有』infected? = true 的 turtle4 D+ o# a: r$ m( l4 C- u: I8 Q# u
但看结果似乎不是这样。
' R. {2 {# ]/ A6 Z; ~+ o D$ {! |2 l2 p0 J' c( d
假设所有符合条件的有 5 笔
' w8 ~# x$ W4 i* |( S/ J; q* M% j有时候回传 1 笔,有时回传 3 笔,是不固定的- i, x" s+ |/ M& [" b
回头查语法定义0 N/ C' C: g \% m+ @' P
with ! A- q. Q& h8 g4 v# O* j3 T7 U
agentset with [reporter]% n1 [4 P9 ?) b, @2 i/ u5 c5 f3 Z
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.
2 `# @- @- y: D3 U它只说回传 agents satisfying the given condition
* G9 ?8 |# O T6 `# ~4 _7 X是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
' x$ c+ f, u* @& C
4 m6 ?' S7 T) m& F想确定一下
" P* R1 f! K8 ?2 G谢谢!
! |- [, P; F7 ?5 _0 s8 [ |
|