|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序7 S' d$ o2 z7 z6 `
其中有一段如下6 V; k% G- O8 ~& k& c
ask turtles with [ infected? = true ] ( f. h: p' d; S" f. l. N9 A
我原本以为这句会回传『所有』infected? = true 的 turtle% J& Y$ K, j" V4 |- B
但看结果似乎不是这样。
: x4 O# Y; O* \/ o3 ]) z/ L, x/ i' O% U' g2 O$ @! S m
假设所有符合条件的有 5 笔- r! v- W- N, w( _. o
有时候回传 1 笔,有时回传 3 笔,是不固定的) C8 \9 K& @ G) O
回头查语法定义4 Z* l0 H/ ]& ? i- Y% R
with
* k7 |3 m) j4 W" G& Kagentset with [reporter]- p# b$ s5 H* V$ K4 \/ d/ k8 ]
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.
2 t) S+ q$ K8 `+ t" H" p它只说回传 agents satisfying the given condition
) S' R0 v$ g ~" p2 y是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
, {( l( t2 V, C# x
/ \. r8 m8 S" u* u" G2 r: J想确定一下) l6 J/ d* i8 r9 [9 n/ p7 a
谢谢!
0 Q0 @) J+ \) b) z8 H |
|