|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序' z" q2 t- [& v5 `- e" A5 c1 C
其中有一段如下. w0 O6 W- z3 Y, _" C
ask turtles with [ infected? = true ]
# R. h/ p4 @' D N @0 ?4 L我原本以为这句会回传『所有』infected? = true 的 turtle
; j2 r. U+ D1 {" T; [3 Z但看结果似乎不是这样。9 q' Q D/ p, U& s9 v) Q/ G' p" [' Q
+ r e: {8 m0 {2 c+ h' @9 Q" t' {! N/ F7 L假设所有符合条件的有 5 笔7 n) m( E+ ?) r& ]3 W/ e j1 M! v
有时候回传 1 笔,有时回传 3 笔,是不固定的
; \8 D; j/ I* r回头查语法定义
. W5 V0 B6 z% I3 f; M! nwith 8 | b1 y# n- I1 }
agentset with [reporter]: I$ S" B* M- ^& [& o' b: T
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.
# h! c( R1 ?( ^! Y7 b9 W它只说回传 agents satisfying the given condition
. O! ]) Q+ \ J8 A I. ?是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
, d0 k8 W7 A/ ^% }7 u" Z6 g. u. _# T: o, ` b
想确定一下$ U: M: X& I5 r4 N. B
谢谢!$ _9 E" _5 Z5 x3 G2 `
|
|