|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
7 d1 D+ W% o7 Q+ n其中有一段如下6 g; d5 m' X& M I4 l; Z( \
ask turtles with [ infected? = true ]
$ {# T, W B% G, f( K d2 m我原本以为这句会回传『所有』infected? = true 的 turtle* I) M/ l* d- W0 N
但看结果似乎不是这样。8 G- `& o" b+ h/ h# O
6 z+ A0 r4 K1 p# ?7 w3 b% q8 N假设所有符合条件的有 5 笔
, b! D6 u% Y2 ~; r ]% X8 q有时候回传 1 笔,有时回传 3 笔,是不固定的4 ^+ ^" v' H( L4 T
回头查语法定义# n" S$ N7 F/ M5 c9 _+ P# V
with
) Z' k: G8 d6 }9 Y `agentset with [reporter]
1 R. }" l7 ^# P) _' v+ ~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.
5 p0 v* f" |3 k% N: |! Q n! @+ g它只说回传 agents satisfying the given condition
& o5 W6 K" ~0 k# N. U/ q是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
# r! s) {# ~! N2 i/ X! {3 X o; `
6 Q2 G; v1 X5 [3 I1 u# O想确定一下) h% w0 v/ ~+ n( J7 _
谢谢!
& m1 G! W% \% |! f2 g( D3 T3 _ |
|