|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序3 s( o% X# G! }' v$ \. \
其中有一段如下! K1 e1 I! w- `( z$ _$ o1 F/ h. b
ask turtles with [ infected? = true ]
: I! u; p6 _3 P7 O H7 \我原本以为这句会回传『所有』infected? = true 的 turtle
! _" f8 M" s0 l但看结果似乎不是这样。! c/ H" z" b) V# g+ o+ W
3 Q# J9 ^: ^& P8 c3 V1 ^! n2 M
假设所有符合条件的有 5 笔
1 a) m$ \2 `: Y* m0 c有时候回传 1 笔,有时回传 3 笔,是不固定的
# X, Z8 {: g5 q( d8 R" Z回头查语法定义
+ b! ?( r( ^5 S) X- P6 w# ~$ H1 ~with ( {. \6 {' l7 G2 W, j& w
agentset with [reporter]
+ o; ~5 V8 c( S1 D8 [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.. g+ ]$ v5 L2 h% K* I* M
它只说回传 agents satisfying the given condition
/ h" X2 o- {. t是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
5 J8 f; N C/ X' k
8 f) ]1 C: H7 m5 a3 \" w5 _想确定一下
9 P/ ?& m- m) ^4 |谢谢!
1 L; [& F1 l. z5 O' L& C, ]6 R: v |
|