|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序/ ^5 w' j( ?* q Q8 ~/ o7 o3 f
其中有一段如下! Y2 N5 ]. _7 p4 [, L
ask turtles with [ infected? = true ] 3 I7 Y' }* D C6 p# b
我原本以为这句会回传『所有』infected? = true 的 turtle- L+ ?2 A) u' J$ T. K2 P
但看结果似乎不是这样。
7 W2 h: E0 ?% Y8 E2 v$ |3 w, \1 n
: U' V; e) _3 Q% y4 R! T( }6 d假设所有符合条件的有 5 笔* Z% M/ Q* M+ n" Q d
有时候回传 1 笔,有时回传 3 笔,是不固定的
+ t# O# N3 Y6 `4 p回头查语法定义
+ b3 i2 C1 d8 |9 q9 Z/ o2 E9 \with
& M- ^6 b: h0 Z% F0 K. z" n0 M& Cagentset with [reporter]
- P' a2 N2 L. j* y* F4 mTakes 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.: J6 l( x% ~- w& f
它只说回传 agents satisfying the given condition5 k* H& x. Z% G
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
4 t3 N+ a7 s$ _& r" D( G+ z( T' H$ }, }9 N4 ^. z7 f9 b+ T9 c
想确定一下6 l, A7 ~9 z( |
谢谢!9 B5 @7 I7 A+ z6 ]( c' `" o2 R2 @" ?$ Z
|
|