|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序! Q5 F2 q! Y& U- W; W
其中有一段如下
6 l. }2 \/ I$ L9 G B$ }ask turtles with [ infected? = true ] 3 i/ g4 n0 I) p3 M4 ~$ L
我原本以为这句会回传『所有』infected? = true 的 turtle1 k! W K& V y: f
但看结果似乎不是这样。
2 m' ]1 |. w' e! l( }* c' E
2 p( A: {6 P9 |2 c! j$ x假设所有符合条件的有 5 笔$ n% R/ H' K A/ @0 b ^
有时候回传 1 笔,有时回传 3 笔,是不固定的
U6 @7 }4 W: V( T8 P1 g: D: h1 \回头查语法定义3 r2 q$ u8 t7 ~3 n' B& k$ f
with ' j+ s. q/ E% F- N
agentset with [reporter]
. m3 t: `( U" \6 }3 ?0 y) ~4 nTakes 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.
* A6 x( a2 i% p: D [& L它只说回传 agents satisfying the given condition- d0 B( m1 W0 z4 o( g5 C2 q
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
, x; Q- }" p0 c' w$ n; g" x. f+ H# o& C* |# _5 D/ V
想确定一下7 g, B3 x% k2 R7 `: n8 V5 o
谢谢!6 [5 h, ~& U( R; C0 E
|
|