|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序) T1 N& Z) I! Y6 k T% H) b
其中有一段如下2 `' K8 }2 L. D6 |
ask turtles with [ infected? = true ] ! v9 j- a' x9 ~7 u' ?6 {
我原本以为这句会回传『所有』infected? = true 的 turtle% M& j2 l: L/ Z* z; `( l9 Q6 V
但看结果似乎不是这样。& ]5 {" g* S ~
- L/ Q, I8 V$ f# m3 C2 f" V1 F S
假设所有符合条件的有 5 笔* `8 M! v: ]% l4 c; W% t
有时候回传 1 笔,有时回传 3 笔,是不固定的+ G6 E+ ~! M# p) R
回头查语法定义2 u& S1 M% g: f4 @% o2 K( R
with . S$ H% O7 N6 i! b9 W1 ^" l
agentset with [reporter]
7 Q# Q2 d& c* [* @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.
; v- k& [/ F% g2 h: L它只说回传 agents satisfying the given condition
6 Y4 N3 i7 b( }5 K+ N% |是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
9 ], k; }( x: X6 F" I8 D. s8 K7 l4 c6 x* V. e- V
想确定一下' z; D" E' A1 D! [3 @
谢谢!
, N: x; K J) e9 U" M: D+ A7 Q |
|