|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序- K0 j" ]! H* J- ]$ _; @! C3 e
其中有一段如下7 k* M% T. ~) ~' H$ D% [
ask turtles with [ infected? = true ]
9 T% e8 A( Q+ y5 H! P* h6 K, g, k我原本以为这句会回传『所有』infected? = true 的 turtle: U$ E- g- K/ K+ ^. F0 j. ^
但看结果似乎不是这样。
' s+ m' T+ y$ A3 u
. H7 {& A9 Q: j0 D' s假设所有符合条件的有 5 笔! u* K" Y$ u9 _0 a8 i
有时候回传 1 笔,有时回传 3 笔,是不固定的8 f6 R) W* a) [- S$ W6 ?# y0 W
回头查语法定义6 p1 t" D& _) q- Y8 q. c) n
with 8 Q7 |# f3 {1 A5 G0 c. O# r% J7 M
agentset with [reporter]" q5 n6 u8 U! `
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.: \, f1 l0 e+ W6 j% s f
它只说回传 agents satisfying the given condition% c% `/ D2 B8 @) B
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? : Y- V# O3 W& N1 x/ e! i/ B! X
# G. H- Y; i. j想确定一下# h2 A# ?6 }. e" I: t9 }- n
谢谢!3 D, P; V7 A- `
|
|