|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序1 }; T% V) g) ~6 S, L" b
其中有一段如下4 e) X6 h3 _4 H7 _- y& t7 l
ask turtles with [ infected? = true ] 6 N: q% m2 V2 A' @/ x. Q- z
我原本以为这句会回传『所有』infected? = true 的 turtle' |: f1 c& g% y
但看结果似乎不是这样。 O8 t1 M0 [" L+ _4 G
. Q p4 z; r" p$ \' Q8 w
假设所有符合条件的有 5 笔
( r$ |9 s8 g4 V* P有时候回传 1 笔,有时回传 3 笔,是不固定的6 s0 N% \* y' @/ \ s5 b& e- d
回头查语法定义% c+ c/ O% z, p9 \4 l. {7 d9 c5 F
with - }2 n ~8 U1 ~4 ~/ H
agentset with [reporter]! M$ c; R) F" S( ]9 b5 w
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.
4 D4 W& z+ i8 d6 n$ g0 u它只说回传 agents satisfying the given condition
& h. Y x; n; C* H% p0 @; V$ H" |! m是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 0 z; l3 \% q" g: t: ^/ V2 r
5 S. l' y% M I/ w1 Z( H8 o5 M
想确定一下
# M8 R+ Y/ s3 J谢谢!
; D7 S3 J% S; `" o0 ]7 }: q |
|