|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序- V1 y8 d( P! B% k7 m! c6 ?
其中有一段如下
4 y3 x% E" g' ~4 Q( q& C8 {( [ask turtles with [ infected? = true ]
3 c ^" ^" {" ]* Z. ]我原本以为这句会回传『所有』infected? = true 的 turtle9 c2 M3 v2 w2 C6 Z( l
但看结果似乎不是这样。" k* f6 N9 H3 G0 t( R: t
6 H m2 G; x. M" T' O, X8 w! Z
假设所有符合条件的有 5 笔/ g1 t+ C+ p* \6 o9 g
有时候回传 1 笔,有时回传 3 笔,是不固定的5 H8 F% V- M! I8 g3 @; C0 z6 n
回头查语法定义
4 ^: p! k- L1 G9 u3 i' g `with
$ m: d* @- @; n. D, Tagentset with [reporter]
1 g* O( \* Y9 X3 X1 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 R& {" V7 q9 X0 }
它只说回传 agents satisfying the given condition
2 K) r! R% D$ |. `: w是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? ; Z8 S) e" n* C
& k& t+ E# b ?# y2 }0 E% ?
想确定一下9 K' _! b* c# O* x8 }2 N F y
谢谢!; s6 j: X5 b! Z
|
|