|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序; d/ H$ P. ?4 M( h+ G* m. |! Y
其中有一段如下6 r# J8 w0 w8 O7 k0 K8 z
ask turtles with [ infected? = true ] 5 @' B+ O, h% J6 d) D" p+ g
我原本以为这句会回传『所有』infected? = true 的 turtle. y0 r P3 M: y) \8 U/ }
但看结果似乎不是这样。, V$ S1 I0 L$ G) c4 ?- Q
9 v. g4 ^/ x( L" ^, o2 W
假设所有符合条件的有 5 笔
6 ~* E- x) @& G5 w3 _有时候回传 1 笔,有时回传 3 笔,是不固定的( ^8 s, h6 c, \- D ]. ^# V7 R6 W2 z
回头查语法定义( m$ i6 \$ j) {5 T- a
with $ B& t3 _! r4 Z7 O; l, l
agentset with [reporter]5 N; i+ T: j* k& o6 A) U {: i# h& f
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. O0 V. ~5 m9 Q# L6 u4 k! Y7 J
它只说回传 agents satisfying the given condition
! J& R2 H1 J7 Y是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? ! N3 J6 F( Q0 E+ {
2 X5 c1 _5 X- L _' G y想确定一下1 B" @' i; d* Q- T r
谢谢!
9 V% ^8 ]5 W1 P0 | }/ {' s6 g |
|