|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序! t9 e& }9 H4 l, E6 M
其中有一段如下5 _8 d1 v B2 t0 D
ask turtles with [ infected? = true ] 0 I$ Q+ v$ v) ?5 U/ U8 K
我原本以为这句会回传『所有』infected? = true 的 turtle. \+ F+ I5 j2 N. M. M+ ] N! `
但看结果似乎不是这样。' s4 z4 v2 H4 V, h" }
# l: k. Q4 j( N假设所有符合条件的有 5 笔+ T" G- a3 d& a. K
有时候回传 1 笔,有时回传 3 笔,是不固定的+ f9 u4 Z: H. N% M' T- L( ?* u
回头查语法定义# I; r) b" U D2 |4 J# p
with ' P3 i7 Y( t5 @. e
agentset with [reporter]
# b! b9 I: d O& @7 m, _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.
! ]6 G% ]" I2 `; b! i0 _它只说回传 agents satisfying the given condition
) c# C% C" z( o6 h. m/ c9 @& ]' I0 f是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
2 v, k; P" j0 |/ M4 e- p9 M
. k) m9 r/ Q( x2 \5 r& U2 M* k0 e想确定一下
& x# T0 T C7 B g谢谢!% Q, N9 j# J4 e. d P5 J0 T
|
|