|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序. D3 Q, c# @1 M
其中有一段如下
& w1 W5 v! e" ^- V- task turtles with [ infected? = true ]
- `( Q3 Z- W, P2 Q: H我原本以为这句会回传『所有』infected? = true 的 turtle' N4 e, n; Q6 h3 {2 g' Z
但看结果似乎不是这样。- f2 b4 d& s( x" v
i2 M% C2 Z- `) i# b2 M3 V* `
假设所有符合条件的有 5 笔
l r4 ?9 y# T: @( B% ~3 V( ^0 _有时候回传 1 笔,有时回传 3 笔,是不固定的5 o7 ^* z' _1 p# ?
回头查语法定义) ?- H: i- ~; @4 x
with 6 @: G) v) _5 B8 B# r
agentset with [reporter]6 v# P8 `+ @! J. S" [' K5 R' i! [
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.
) J) {6 P o4 s9 s0 f它只说回传 agents satisfying the given condition5 @8 k) E7 t; d c8 R
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 4 V5 ~+ K2 ~* P
' j! j3 [. t% Y" k N想确定一下% m; h6 I$ r1 ]" D% O+ w4 Y
谢谢!
8 \" d% D6 m5 P/ R |
|