|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序- e/ s7 b* A6 K7 {2 l
其中有一段如下 N0 q1 S- [7 H
ask turtles with [ infected? = true ] 7 ], G3 s' [' V+ P% d% r
我原本以为这句会回传『所有』infected? = true 的 turtle* f+ ^$ c- A M9 v2 W
但看结果似乎不是这样。
. ]: `4 U5 }' [& X& ~, G! M
+ b- w7 {# W! [' U J7 l) e" p: {, I假设所有符合条件的有 5 笔
( ?2 X( U* W" X, C有时候回传 1 笔,有时回传 3 笔,是不固定的
9 P: o6 j7 Y9 n7 m( V- x% G( }回头查语法定义
7 f: T2 o/ v) s+ g$ x$ Z* E8 Cwith
( ^3 M6 i4 S9 {1 ragentset with [reporter]
, s- D. o6 P F4 ~6 PTakes 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." J! E; E$ P2 P2 ?% `! @. E
它只说回传 agents satisfying the given condition* ?$ v( e) \6 I- H0 j6 i+ E/ l
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? - F9 ^3 `0 t/ o' F* e# p
$ A/ y4 r& G; S0 w* `2 `+ {9 S3 c想确定一下- A- K& F& h5 x+ G+ t
谢谢!
. y- s" [, h0 S6 ~8 ]+ F, S |
|