|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
- J' R5 X3 Y- ]4 v/ o其中有一段如下2 m& D7 ~- {% V
ask turtles with [ infected? = true ] " d0 o6 n4 A r" q& U4 F
我原本以为这句会回传『所有』infected? = true 的 turtle
, O; W z: T. }* Z但看结果似乎不是这样。
, J% j4 }6 `' n6 u& {" Q8 l: u3 a& R& w- p, K9 R- N- u! W
假设所有符合条件的有 5 笔
- j) y( O% \) K: X" ^' y有时候回传 1 笔,有时回传 3 笔,是不固定的) |( t- J" |! t: ?4 R
回头查语法定义7 L! [) g2 }$ V* f/ k* P0 l2 f
with 2 K0 a! W! H3 @0 I- ?& @
agentset with [reporter]
5 I. e* a v1 Z! x* [: mTakes 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.% }: E: k V8 u6 G: {. @% I
它只说回传 agents satisfying the given condition
. P/ S3 F; x6 M是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 0 _" Q, M8 j7 ~' {( f
: }6 G, }& Y9 @$ r0 z- s: J; @. Z想确定一下0 v4 ^* C" m* |
谢谢!; O- N, R+ u% M" Y+ U1 e
|
|