|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序+ F$ Q. g6 m; S( Y1 u0 S+ Z( o6 Q
其中有一段如下0 v0 F; |# L: [* l7 {
ask turtles with [ infected? = true ] 9 z1 T4 Y& G1 P. J, R3 _" Q
我原本以为这句会回传『所有』infected? = true 的 turtle
: V1 f. [4 {& c2 ^+ A! r% _, `$ V* ^但看结果似乎不是这样。/ H1 \" s$ \% M3 q# ~( \
0 m3 n& A/ g+ S( _3 ] X; B假设所有符合条件的有 5 笔
3 U. l+ k1 `6 x' \有时候回传 1 笔,有时回传 3 笔,是不固定的0 e1 \+ e' u1 f$ }) l8 U% [
回头查语法定义$ v& @% s X- l) J* `1 s
with
! q$ O- m8 k% M: e) h: e4 {agentset with [reporter]/ n9 k4 S5 R0 ?. d. j, ^; ~4 d
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.
/ @; w' N: g/ j o6 t2 @4 H: v它只说回传 agents satisfying the given condition
0 `( D, w: P" v% S/ l0 j$ q# I是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? ) H2 K. x0 i" J9 h& {( s, O+ I
o E6 U2 r5 O0 o, h
想确定一下2 V o0 ~. j7 G$ C
谢谢!
) G6 s5 }2 d6 W0 A; ^ |
|