|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
: \" V8 u3 v% p( i6 h4 F, ~2 n其中有一段如下$ y7 B- h; R& Y7 Q
ask turtles with [ infected? = true ]
! U( Z/ j' s3 D- C l我原本以为这句会回传『所有』infected? = true 的 turtle" \: g& a% q% |* J2 j! b. G
但看结果似乎不是这样。
* C8 _" m' Q5 u d7 q
9 |$ L( {: N' K0 w1 ?8 T. R假设所有符合条件的有 5 笔
! P4 u5 p3 C& e* L" U有时候回传 1 笔,有时回传 3 笔,是不固定的
& x7 [! E9 A' H) D0 O: v回头查语法定义
+ I1 e9 I7 @- U( i9 u H4 D0 o Owith * X0 r7 X- A4 i' V1 I9 J
agentset with [reporter]3 R3 L4 K( A' e* C
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.
3 }/ N7 g% E* A0 }: A它只说回传 agents satisfying the given condition3 @* I, G% O% j- N6 v4 L) [
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
0 ?" {) }3 ~! S! U( p0 h$ L
; a2 z/ u; E+ ], i: `想确定一下
* ]4 G$ |4 l) n谢谢!
' a" t$ B8 ^1 {* U |
|