|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序) b# ]2 j! x* g: H# T6 n* e( p0 w
其中有一段如下+ \& p7 E. f" m1 L
ask turtles with [ infected? = true ] 3 F2 u& c4 G1 K$ p( `0 S6 o
我原本以为这句会回传『所有』infected? = true 的 turtle" v9 D- j' _9 o
但看结果似乎不是这样。
2 [! x! w' U, f5 _- J
/ l" w, x1 T' I- H假设所有符合条件的有 5 笔
8 L, K d. G/ W- u0 N/ R有时候回传 1 笔,有时回传 3 笔,是不固定的* |" r y# V& z" H0 B# Y/ R
回头查语法定义* X/ E6 r0 A5 D! G3 s% A2 `
with , _& Z$ O5 x* W) w; A) }; g
agentset with [reporter]
) S; b0 h6 I! STakes 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. V9 E5 N; L' T' e5 G它只说回传 agents satisfying the given condition9 |" g8 S" I) G7 o6 h) w
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? $ H# _ k( ?: B
! _* Z9 D, F; Y, S' g( H想确定一下
4 y0 S' D$ v# J# i- c谢谢!! P; W4 `; K3 s% O
|
|