|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
, F+ I- f) f2 m8 d+ d0 J9 ^1 N其中有一段如下' }4 F+ k3 K3 |0 x$ L
ask turtles with [ infected? = true ]
5 d A# e( ^3 t: K1 y8 ]我原本以为这句会回传『所有』infected? = true 的 turtle; t5 a' ?/ u9 l0 M/ q! w
但看结果似乎不是这样。
1 N# L, Q: i) J& f u8 W
: b$ q0 n7 @: J% T: C! r假设所有符合条件的有 5 笔
! ~) X+ M/ }& K- {有时候回传 1 笔,有时回传 3 笔,是不固定的
$ w% }! q' {5 p8 G0 i回头查语法定义8 ^* x0 v$ c3 p( Q2 B$ [+ J1 P! o
with
# |/ W9 }9 k9 a$ y3 |agentset with [reporter], m; Q( N7 ?. Q8 S/ {9 k6 d
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.
9 U3 ^- D+ {; C5 f2 Y. K它只说回传 agents satisfying the given condition
# b* F* i5 m+ ^1 N1 k7 @; b是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 9 r6 a2 y2 ^# T3 ~% m
4 y+ g# v, e+ }& _6 {
想确定一下
( W' \# u$ i) S7 g" ~谢谢!
; X7 n, V$ k, L% a& H, g |
|