|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
% ^& W. E+ R$ k, V& M其中有一段如下! n( H' Z7 F' S2 {( G
ask turtles with [ infected? = true ] " X B, B; Y8 t/ o- n
我原本以为这句会回传『所有』infected? = true 的 turtle7 d1 l* S6 g& d: i$ }" O8 M
但看结果似乎不是这样。
/ g$ V1 {; ?" H# u: u
6 z5 I+ y _9 S( B2 f假设所有符合条件的有 5 笔
; i% y/ G. c, ]7 i3 N9 ?. D2 n有时候回传 1 笔,有时回传 3 笔,是不固定的
% Y7 I5 _9 N4 j* {4 w2 u, n回头查语法定义4 y+ v; j0 q7 W" F$ N
with ; E8 T! ^) z& }& q$ @
agentset with [reporter]
7 }+ ]8 w) o5 ?% F' z* g" D" xTakes 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.
; n3 @* L% R J它只说回传 agents satisfying the given condition5 F: o7 r0 R+ m9 v, D0 j" r
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
$ Z$ N. V5 e. ? }" q0 A/ }5 C! }8 f s! [9 r
想确定一下
1 e1 k- s+ M4 g9 u谢谢!
3 o7 U+ ?" A5 f: f. t |
|