|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
$ u- W: h" B8 b其中有一段如下! Z& A( s4 C) u6 E; c1 Q5 U
ask turtles with [ infected? = true ] * V: B8 ~0 f9 |" Z
我原本以为这句会回传『所有』infected? = true 的 turtle" k" a- S, ?/ I0 u: j' L% M( C/ w
但看结果似乎不是这样。
* t n# P7 J/ e2 C4 a$ U* p' M. \5 O$ ^1 s* W: g; U5 }
假设所有符合条件的有 5 笔: _! c% L8 ?1 G( J9 q
有时候回传 1 笔,有时回传 3 笔,是不固定的/ ?! y* p8 L. V' z
回头查语法定义, d) g: E) F& P
with
! Z& s- c8 O' ?% e' Aagentset with [reporter]
/ R* y9 O$ Q- A9 H# g9 ~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.5 ^8 \' M1 B/ `$ s$ J8 z
它只说回传 agents satisfying the given condition
9 ?$ m5 O7 E) Q7 _6 |1 u" y是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
6 g; p9 F; h& z! \: H
+ B7 s( E: M2 e: Q5 T想确定一下
/ G& k' Z& N% ?谢谢!, b, @& ^3 G1 }% J0 e2 }5 T; p
|
|