|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
7 I% f/ a* E5 d0 K% \) p4 t其中有一段如下! R' c; f2 K+ x* v
ask turtles with [ infected? = true ] 7 h2 ]7 [+ _4 Q0 @! I" T7 p7 i
我原本以为这句会回传『所有』infected? = true 的 turtle+ T9 z, k f0 [; G* x4 X, C
但看结果似乎不是这样。; ~7 w6 m8 ]! V( Z1 P( y
6 g8 J# @. |7 W0 z! L. l
假设所有符合条件的有 5 笔 z. l! \5 h( L$ M; w2 |
有时候回传 1 笔,有时回传 3 笔,是不固定的# l' b8 s% O" ?) j* w' p2 f. Q0 m8 G
回头查语法定义
: _8 x# b* I" |, K: L/ ~( L; p7 [with
" k4 G. t: Q# Aagentset with [reporter]
5 m. l$ J3 n* J$ ?( W6 ?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.& J0 \/ [( M8 H
它只说回传 agents satisfying the given condition1 i# g. v* L1 N( ?
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? , T4 h+ @9 h" h" D. q* b: P
% X) t; `7 i" I: k8 T想确定一下
# @5 z; Y0 S2 j6 t* `, i$ a谢谢!
8 x# h6 c. @6 [* H |
|