|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
4 s- G6 N) D0 `7 N1 i. ^1 x; S1 w0 L其中有一段如下: B6 D; c: f. G' F z( M: _7 R# T
ask turtles with [ infected? = true ]
1 w, x& k$ x/ O" r% m# k" x4 J+ F我原本以为这句会回传『所有』infected? = true 的 turtle
0 X5 c$ [" Z& O/ ]8 d& U1 i但看结果似乎不是这样。
+ w4 J; X; n: j, q4 ]- T, ]) F& F0 ]/ z5 {- y. H4 E( z* i
假设所有符合条件的有 5 笔( N* f0 q& a+ B! L' ]% V0 @8 i
有时候回传 1 笔,有时回传 3 笔,是不固定的
^' Z" U1 D6 f w' m回头查语法定义. }: X2 a) p- T, @1 O
with / P# W# t" J+ J6 `' @5 E- L& d
agentset with [reporter]
8 R) \4 a* j: Y3 k3 ~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.
& m9 x5 I# H: b E/ v- t. t它只说回传 agents satisfying the given condition" P! K5 _" G( U- U6 x
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? , {5 E, N7 G! |. K3 ^
# G x% D5 [, G/ B$ s! }" G. D想确定一下( u: A7 D9 X, W7 @2 h& ]' A
谢谢!0 s3 F& Q8 ~9 I6 d- l7 i
|
|