|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序# D, E3 A+ G# P- z+ `6 S9 g4 v
其中有一段如下
3 j8 D$ e0 p: Jask turtles with [ infected? = true ]
! I2 d2 d6 G( p8 z& N8 w我原本以为这句会回传『所有』infected? = true 的 turtle2 Z- \/ G' e& d0 g
但看结果似乎不是这样。
$ {; P4 c. H- r* k/ k1 W8 q5 S# v+ c
假设所有符合条件的有 5 笔 X0 @4 Q4 w! z* @+ V! Q5 S2 \
有时候回传 1 笔,有时回传 3 笔,是不固定的
# ?& H }: a1 X; T& }9 V回头查语法定义+ K/ U5 z' T! }( `
with
" `% F' q* A5 H8 A; T# E. ]agentset with [reporter]5 |) B4 L+ n0 Q
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.
: C- |# f; f; d" i, F8 D它只说回传 agents satisfying the given condition. h6 a3 A4 t- M' J5 Y
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
8 G1 L8 N# o9 X& u2 t, w5 p7 [" H9 B; P, ?- c( a6 d
想确定一下
+ j9 U; ~5 D, n3 x" [7 W谢谢!5 ~" k& t& ~; X: A* m
|
|