|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
4 Z4 v8 ^ \6 l/ M( a- p0 T其中有一段如下9 m; b6 K9 K" r) g' d) ^
ask turtles with [ infected? = true ]
6 I" g. Y" X) B我原本以为这句会回传『所有』infected? = true 的 turtle
0 V* p. [; z e! {/ k4 I9 q但看结果似乎不是这样。
# t) {& E- Q9 Q5 s4 D7 S s7 V* h/ A4 d2 e4 p, ^! X
假设所有符合条件的有 5 笔4 e+ e! [) a: |+ ]1 y, \8 M$ w5 C
有时候回传 1 笔,有时回传 3 笔,是不固定的: V; [+ [4 C1 H3 o2 j: l
回头查语法定义
. v$ ?* F, N8 K5 K; ewith % A9 t- A7 O7 p* t$ o
agentset with [reporter]1 x( K0 u6 y4 J$ d9 O5 ^2 t- H
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.) d2 V5 A7 k# ~* q" b+ L
它只说回传 agents satisfying the given condition
7 D) u( H' c: Y. N& F是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
# p! r( m" E0 _3 u7 d5 Q( _! n
+ D8 E6 s; S1 U" j2 G) W* `想确定一下5 D" b) I6 g9 u& p# X0 v4 ^" f2 ?
谢谢!" V: f9 Z3 U2 x" B& g
|
|