|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
: y! j+ F$ a6 y, n+ ]3 U其中有一段如下" T) I }$ J6 u7 A; Z* n
ask turtles with [ infected? = true ]
# G% @. q9 ]5 A" m' q& q3 h: o我原本以为这句会回传『所有』infected? = true 的 turtle
: h7 K% z+ }) o' _/ z$ K+ l9 d但看结果似乎不是这样。
( P, ^$ T; \" z0 e- ?3 W( u$ A- k3 ]1 x6 | C! T" y: Z
假设所有符合条件的有 5 笔0 b$ f' L* a4 J$ y
有时候回传 1 笔,有时回传 3 笔,是不固定的$ Z) b S s! |! F
回头查语法定义) d4 d! L( y$ ~. c
with
' E- t8 @6 b; i1 {) T! N. uagentset with [reporter]) N+ r& L) k0 T2 j7 v
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. h' d& B4 ]& M9 \/ J* S" r2 L) k
它只说回传 agents satisfying the given condition* a: _. e1 n8 t, Q
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? ! ~. v8 D% R0 o. Y
0 x% U4 w. @! w7 J" X想确定一下
8 O) m8 |' B0 i- Q谢谢!
& T! n5 v1 t; w& @! X |
|