|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序( J F! D! D, H+ T! r
其中有一段如下
3 D- Y; R3 L2 v1 l' H9 rask turtles with [ infected? = true ] . e4 c: M: l0 n5 v
我原本以为这句会回传『所有』infected? = true 的 turtle% n& H. g3 Y" Y) m4 J
但看结果似乎不是这样。' F! q( S/ [; E( h# |0 a" g$ t
4 O: H+ B8 }. D [2 L" d% v假设所有符合条件的有 5 笔8 f4 d$ ^4 L" v2 [7 L" g
有时候回传 1 笔,有时回传 3 笔,是不固定的1 ~" e% P6 @5 M+ o; V
回头查语法定义4 r) e/ h" y7 d3 a) R* V3 R& M
with % _" D- Z5 l1 Q
agentset with [reporter]
* T, K4 E$ |+ H. `1 ~8 FTakes 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., ^9 |( N- A0 U* }( ^
它只说回传 agents satisfying the given condition* H2 X0 U# Q/ t' `* @' o
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
3 c. t7 i1 d; ]6 b9 F
, ]2 N6 q& x6 X( x6 k! v想确定一下$ q$ g/ {; q, ? Y. H6 {2 F
谢谢!3 _- H$ {; {( I$ P' h5 O6 s
|
|