|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序" E4 V; v+ E1 v+ T; u, x
其中有一段如下. A6 F6 Y4 W! M! h2 R
ask turtles with [ infected? = true ] & O3 C7 ^- r. r1 ]. c
我原本以为这句会回传『所有』infected? = true 的 turtle7 s* F- T0 F+ y3 V
但看结果似乎不是这样。+ ]8 ~) M5 C* y
9 F5 T5 L4 J+ K8 f' [% V
假设所有符合条件的有 5 笔
[ i% @& ?( s( q' G) \; \4 _有时候回传 1 笔,有时回传 3 笔,是不固定的1 N+ t) c6 [1 u5 k0 f6 U
回头查语法定义& O1 q7 e# D- b0 \( m5 G
with 0 x5 y1 R7 l5 `9 m$ o7 j9 u& \7 w
agentset with [reporter]
; Q1 _' K1 w0 a" y9 W! k4 gTakes 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.
6 e) O, g3 k( O1 V3 I它只说回传 agents satisfying the given condition! o! G; h# Z* O. M7 K. M
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
" x! r# q4 F. h0 Q
7 S. s8 B$ b8 f# d2 W: N想确定一下4 C: x% e: A. D8 l9 `
谢谢!
0 R+ I6 V0 e) G @ |
|