|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
+ l X) G. I1 o其中有一段如下
0 q; O. q* L2 Aask turtles with [ infected? = true ]
: O! ]2 k2 d9 L# f W' J& h我原本以为这句会回传『所有』infected? = true 的 turtle) {! T8 r- U; b, o' C2 S8 S3 W
但看结果似乎不是这样。$ j* [# t- |' X, i/ J, [
7 Q5 i! ~& W) S% A2 ~假设所有符合条件的有 5 笔
& L9 l r( V d& p+ O+ O0 |& {有时候回传 1 笔,有时回传 3 笔,是不固定的
! B" N8 N4 ?# b( g, j, Y2 D% p回头查语法定义+ M% J7 M8 r* z7 R8 @* v
with U+ R+ `! a# }% f D
agentset with [reporter]
$ e" L2 {6 ?; l) f% OTakes 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.
6 I3 M+ ~3 Z" c9 n7 k它只说回传 agents satisfying the given condition& q1 ^5 S/ P9 F- f# A2 G
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? * L* o7 z5 ?8 i! c% x0 |; h
/ m" r" v u$ u* _, K9 {' }
想确定一下% j1 _. q0 j* Y$ |4 l
谢谢!
' b6 z* H+ d6 E; j0 z: T |
|