|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
$ o! K ~+ X+ E' A& T$ | `其中有一段如下# H$ |$ \) j% w" I8 @1 V6 v; h
ask turtles with [ infected? = true ]
, B; |. B% e8 J# j4 h6 i我原本以为这句会回传『所有』infected? = true 的 turtle& V% v) ~8 V8 D
但看结果似乎不是这样。- g. z1 R! `8 I/ \8 |' [6 \# d
* x( r& h: I( k _* x* P$ W假设所有符合条件的有 5 笔( L! h" V& x: i2 Y& v- G1 W
有时候回传 1 笔,有时回传 3 笔,是不固定的) @( e, v6 d+ I: s3 F
回头查语法定义* T7 ~* |; C, i7 J8 A
with - t* v& o: V3 O/ G; E& w% _! V
agentset with [reporter]3 t( [0 I" n F: F
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.
4 u' o- g' s* C5 R它只说回传 agents satisfying the given condition
# j/ w" b7 [. m5 L% P+ x9 ^是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
+ C: s& O: \% E( i0 Y
, r* R9 p4 p- A, ~1 b7 V: E1 U想确定一下% h4 u* _$ T: q$ D, q
谢谢!: a6 `( Z9 ?8 |2 [. B3 T4 v
|
|