|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序% q( \+ ]; `3 Z6 k1 R% W- U' k
其中有一段如下, M; d+ I, Y O+ J$ ?
ask turtles with [ infected? = true ] 1 V* V4 b) H5 q* K. y6 [$ G" C
我原本以为这句会回传『所有』infected? = true 的 turtle
3 {9 D0 W: e' S3 k1 ~( v0 p但看结果似乎不是这样。
5 ^( g( _/ d2 }- j0 `8 M
. N c0 ^- |' _- y3 d假设所有符合条件的有 5 笔
- _, b3 f3 X6 ~7 |& f% ^有时候回传 1 笔,有时回传 3 笔,是不固定的' G) L- d4 t3 K2 U6 W* Z1 W
回头查语法定义
, Q+ e0 ?6 ^7 J) v6 S* u+ ?" Kwith & S, _5 H. K# m- W h& F3 I
agentset with [reporter]
` u4 D8 |1 S8 q, Y( i* W. x1 ]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.
7 X3 [0 G' w0 l# ]* x& ?它只说回传 agents satisfying the given condition
0 o* Y1 V. W- F8 N; a% H, s是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? , J; S1 c8 N. m$ p1 f
) c/ _7 Q0 R- K1 a8 T" R8 O想确定一下
1 @ t4 {$ n6 Q, [! m( j0 R谢谢!7 {( `6 a8 W. G7 ?4 r
|
|