|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
9 p0 w9 D4 |: |7 ^/ ~' i1 m其中有一段如下0 J3 H$ f6 x" x$ s+ J# v+ o
ask turtles with [ infected? = true ]
* e3 k# o4 g9 S. {: K) d我原本以为这句会回传『所有』infected? = true 的 turtle+ K6 L# g0 e @% P
但看结果似乎不是这样。
# X% x' ?, T8 N6 r
+ Z2 R8 U. o1 [% m假设所有符合条件的有 5 笔
- C P' A8 A" P有时候回传 1 笔,有时回传 3 笔,是不固定的9 t& J0 ?7 @* b
回头查语法定义4 \& [( n: x& M0 e' m& J8 {, j
with 6 u8 o$ ~+ A& T' g' z+ ]
agentset with [reporter]
5 O/ t# r6 ]# g. kTakes 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.
5 T9 `- z. ]" Y1 X) m它只说回传 agents satisfying the given condition
! P7 Z' X/ b& ]$ k! S6 S, h4 j* o是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
4 f) l5 N/ O& M6 x& H9 W" h- x
2 i, c' H& L: l: A+ u& K想确定一下
7 G& d; |! u* Q6 Y. O. _! J谢谢!
2 w' d' h9 V9 i; o |
|