|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
( }& ]9 f) k- F其中有一段如下; X9 N# G' R i" M/ _) L1 {
ask turtles with [ infected? = true ]
9 d, m! H8 B/ r" {5 ~) Z/ d- j我原本以为这句会回传『所有』infected? = true 的 turtle/ _4 d0 I6 Y, o; d: v# k' r
但看结果似乎不是这样。; U9 G8 a H( ?& E* `# a" V
& n1 W7 C, K0 ?" D
假设所有符合条件的有 5 笔
- D$ O- ?2 S$ L% d0 X" E8 k有时候回传 1 笔,有时回传 3 笔,是不固定的
9 X0 ?5 l: B$ m/ _0 t( r回头查语法定义
0 I) x. i' ]: S6 `9 ywith
! ^6 \/ G3 A% [6 Tagentset with [reporter] O [0 c2 T; s; Z, \2 _& A! z1 U
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., E. V+ S e7 \2 l0 i
它只说回传 agents satisfying the given condition
0 U0 L3 E. |. u# U. j0 k6 D. v是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? : B* A( d/ Q( F4 \7 H
" V! _7 T/ t* i x G" [$ j. ?
想确定一下; {; C9 C' O" a! b+ g7 X
谢谢!
" b3 n2 t5 h1 j0 A4 P" p |
|