|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序; U' @* \4 h" x% w$ M
其中有一段如下
5 s: m) _ V9 v9 b: `ask turtles with [ infected? = true ] 6 y. D5 l3 {: H! H
我原本以为这句会回传『所有』infected? = true 的 turtle+ F2 @) e# \$ z. [
但看结果似乎不是这样。
, }; l3 o9 @' `& f$ _; c) I$ [8 A+ |3 [' O- I) _5 g3 t
假设所有符合条件的有 5 笔
~: K0 V- E) C, E. E有时候回传 1 笔,有时回传 3 笔,是不固定的
& a" G0 q& _2 H* I1 w; z回头查语法定义; e. o5 m. C ?
with
+ I2 t. \0 a; n- Dagentset with [reporter]- t U" i1 G8 C* S2 M Q% N
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. t# p) j: l+ }) u! g8 v
它只说回传 agents satisfying the given condition* X/ q. N. v: d S' ?+ D% ]
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 9 {" t7 H+ L2 ^ |
4 ]7 G+ i- f [* ]* x1 N. _) x# \! T
想确定一下7 L% ]$ y3 `! `6 {' C
谢谢!
2 z/ {% ?; g8 f4 Z# e; k% P$ S0 E7 [ |
|