|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序1 A& D: H0 j5 c4 v# n
其中有一段如下0 ?2 U b% L9 J+ _
ask turtles with [ infected? = true ]
0 D, t! k( t |' K+ T4 B- \" x我原本以为这句会回传『所有』infected? = true 的 turtle* _( h4 t2 D$ Z0 [9 e8 B
但看结果似乎不是这样。
" a- w" r# u) G+ h+ `9 P6 {/ p5 j N" v( f1 V
假设所有符合条件的有 5 笔! e0 o# V& g. H* x* r) f
有时候回传 1 笔,有时回传 3 笔,是不固定的
7 S# i7 Y3 k2 [0 h6 F* z回头查语法定义# T; U W# `% U# r" A# N
with
( E: Q# ?+ T/ X. g6 X! z3 K. oagentset with [reporter]
; d/ a* w/ u. K4 E, B/ u; Q, ITakes 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.0 l7 @7 ?# Y( x
它只说回传 agents satisfying the given condition) a/ w& }9 l5 N/ i2 |+ y! o5 [
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? ' b% O2 o8 C2 u: C9 a
. z' T/ S3 C! b0 C8 w4 U想确定一下
& j$ F& _1 {' r+ l- V谢谢!; K" g7 |# {: w0 g. ~( n$ [
|
|