|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序( \* }6 z% _; {- f
其中有一段如下! {9 y+ k( i; [; u% |+ z F, i' n
ask turtles with [ infected? = true ]
; c5 q. @( v. ^! A- T2 j; m `* M我原本以为这句会回传『所有』infected? = true 的 turtle C1 ?+ I* k1 {2 e) m8 L5 e
但看结果似乎不是这样。8 i- |$ e. p0 R Z
; N7 { G& G' v! g1 Y6 d6 ?假设所有符合条件的有 5 笔
5 |4 @* ], m+ u% `+ [0 e4 n有时候回传 1 笔,有时回传 3 笔,是不固定的
/ n2 t& r% q, w) D6 E回头查语法定义; x) j g+ ^! t7 N; X4 y
with
& q! `" |! f9 p( }" n$ X" pagentset with [reporter]3 g7 L* H: N' R6 K( c, O ~0 U
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.
9 w8 h- g S+ a4 \: z+ H. Y; n它只说回传 agents satisfying the given condition; G+ Z& h$ t& d. X. ]6 b
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 4 b* f3 T8 q C8 a/ z
) Y; b1 B& T: E) m想确定一下
/ r! e0 N7 d; o' F% c# _, {& r谢谢!) g9 \) I; M& d2 z
|
|