|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序" g1 Q8 V- M* D$ f, H
其中有一段如下% f/ E+ v ~) j* Y
ask turtles with [ infected? = true ]
9 S: q+ ]* Y9 U( ~我原本以为这句会回传『所有』infected? = true 的 turtle
- G0 F$ \7 X$ d Z! L1 r; P3 \但看结果似乎不是这样。7 ], e# o9 W" r8 x) l* D3 x
) @* }& L- Q( w1 Y s6 M4 A: d假设所有符合条件的有 5 笔
9 L0 W* E7 S) d9 S$ E有时候回传 1 笔,有时回传 3 笔,是不固定的) m* W) ^8 B9 ]; }) a3 B
回头查语法定义
3 e7 k& `- y3 pwith
- ]. W. [7 ?& b8 c5 tagentset with [reporter]1 x5 _" ^+ |5 M1 `5 B4 U' e
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.
8 P! i1 ?' V. S它只说回传 agents satisfying the given condition j0 I6 V8 D {6 u. ^- H
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
0 S4 g$ d) @! V, i G ~/ `$ l
. D2 z! p* g; j( a6 J2 e想确定一下6 K; k( K" K& _9 j/ q3 ?" A0 T
谢谢!8 r- X1 P# N! ~1 `) b+ G+ m( v
|
|