|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
9 O7 z# x$ D- D2 y+ R其中有一段如下3 ]4 x5 ]9 v& g m+ v/ `
ask turtles with [ infected? = true ] 1 g. l- F* k9 M4 q) p( d
我原本以为这句会回传『所有』infected? = true 的 turtle
+ \8 K6 l9 N- i4 I3 T但看结果似乎不是这样。
% [. S, |. t1 t. i* ?
) K" F# \( @& _, I假设所有符合条件的有 5 笔
- P( D- g! K6 q, @) p6 y有时候回传 1 笔,有时回传 3 笔,是不固定的
4 P2 T( }; y: T回头查语法定义% Z0 f W. i& p) G6 v; r2 T3 N
with
- u3 h9 g" B; j5 _agentset with [reporter]8 ]* G7 B; D/ _3 K! w i: |
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.) f; [& v/ v' ~
它只说回传 agents satisfying the given condition5 j: s6 b9 ]2 \) }/ z7 o9 i
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
( ], e! U6 Q4 Q" f1 u- K% j
4 ^, P+ t, u; l1 y/ Y想确定一下
3 r$ _" t" ^9 C谢谢!
; ~& L l) ^0 y1 H |
|