|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
' T/ W4 s1 b1 C" b3 E/ V# x- ^其中有一段如下% H: W' C8 g1 ?/ b
ask turtles with [ infected? = true ]
d. F4 }/ \- v9 W: N: [ ^我原本以为这句会回传『所有』infected? = true 的 turtle
; `9 T! {2 i' P1 H5 l" L但看结果似乎不是这样。& @3 {1 K0 Z1 ~; Z# l
' \1 H4 Y- I3 h8 Y6 x假设所有符合条件的有 5 笔
. W0 [ T0 S/ _4 }5 ]3 l( q, C+ J有时候回传 1 笔,有时回传 3 笔,是不固定的' m; \- M: d1 N- x+ ~1 `1 u. O
回头查语法定义, x6 v5 t8 F& F6 W! l2 a) x1 a
with . b0 D. R* u: E; l) [* ~0 t7 Q
agentset with [reporter], v! W( l' G* V/ {/ H
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.: O+ r; H; i% c% ^( D7 ]4 ]. @
它只说回传 agents satisfying the given condition) p$ g% A) g( T/ `1 R9 e
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 6 l' E6 o6 A4 x2 N" d0 U" f; O% g0 U
, j1 J- I& Y* z B$ ?& Q$ M9 l n( i
想确定一下
$ q2 d! W7 P, {1 V+ s) I5 V$ n7 X, ?7 Q谢谢!$ h: Y' ]) k2 R8 x" ~0 @
|
|