|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序# O1 q. O* P6 t+ Q9 m) X& q. v( C7 [8 Y
其中有一段如下2 \" d- {5 V3 X S+ X8 j `
ask turtles with [ infected? = true ]
4 ^$ s/ C, B3 f8 k2 ~2 Z我原本以为这句会回传『所有』infected? = true 的 turtle) e& Q, b# Q6 A9 U; Q& R& j
但看结果似乎不是这样。8 C9 E! G5 e. T, ~6 a
& j/ l. j; L$ S& U$ u假设所有符合条件的有 5 笔
9 o; r k4 a; X# x' |* I有时候回传 1 笔,有时回传 3 笔,是不固定的 G. O4 n% }' w( B
回头查语法定义! F- V C+ a- x% F e6 f
with 7 X/ Z) s5 U: e
agentset with [reporter]
. e3 b& |/ T6 \% @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.( `; d4 I. \$ d/ i. J$ y2 I7 J
它只说回传 agents satisfying the given condition) U# S) x! g" j. L0 a
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 3 { A. ~2 G/ a% m8 |6 ^4 ]
; K) p/ @. y7 g( \
想确定一下
7 g: a: U9 n( m u# X& x谢谢!# L( M1 D5 H8 }' j& T
|
|