|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序$ U3 B8 N6 h1 Q# [# l( y- k( Q$ Y
其中有一段如下* l6 o/ ~1 \, B' ~# p
ask turtles with [ infected? = true ] 8 u( ]+ K2 z- e1 b# ?* R
我原本以为这句会回传『所有』infected? = true 的 turtle! u) C2 U& {, m F5 h4 ~
但看结果似乎不是这样。! T4 D. S; W( Z7 j/ E0 V1 x4 y/ \
1 U8 r4 v$ t0 r2 S: d
假设所有符合条件的有 5 笔$ K4 v; U" M8 E; }
有时候回传 1 笔,有时回传 3 笔,是不固定的, h- n$ _ u- v; P% M+ x
回头查语法定义4 C1 M2 |+ a+ P& v
with
- }$ h) r+ V' D) ]3 Aagentset with [reporter]
) q3 {: }1 ]+ x9 L9 @+ j) K+ STakes 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.% I9 H) h w/ e
它只说回传 agents satisfying the given condition5 I+ F; N3 U' k
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 7 R9 x; a3 z1 z% V; ~
) v2 u6 n0 U X4 S4 ?( ?想确定一下$ c3 v |6 I! `- [. ~6 s
谢谢!
: w8 T6 k0 ~' U |
|