|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序- J" S: C% ?9 j5 @
其中有一段如下& d6 y" m4 \% |9 g0 x1 G
ask turtles with [ infected? = true ] . t* }- M" v5 v |. w
我原本以为这句会回传『所有』infected? = true 的 turtle9 W& v1 R9 ]+ L1 K2 |
但看结果似乎不是这样。
C, U* X9 u+ Q: k/ J/ N
$ l+ j/ O2 q: G% `6 H; j5 [' c' s$ e' f: G假设所有符合条件的有 5 笔4 f# [: |8 a$ p4 e% ^
有时候回传 1 笔,有时回传 3 笔,是不固定的. S# Z& G# z- I/ t
回头查语法定义
0 }) {( C) | J- U( N3 Ywith ( x! M* z! I$ [
agentset with [reporter]
. _( X/ j' ~0 G hTakes 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.
" K6 U6 i* K: i( n: S2 D它只说回传 agents satisfying the given condition5 \- U+ @, w4 |! x
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
* H; C, g- Q4 L* }. V4 q, |8 j) B8 C. I1 X, u4 Z" I' o3 }+ w
想确定一下$ T7 P! \8 E8 Z8 L( ?
谢谢!) I5 U$ { _ L
|
|