|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序- a" p2 {$ S. a+ F, C7 z
其中有一段如下8 W& F, Y3 _# W- c, g0 O6 K
ask turtles with [ infected? = true ]
) c" H8 M$ K" q, N, m( C1 m我原本以为这句会回传『所有』infected? = true 的 turtle2 e0 n5 S6 l: e" |* m( U
但看结果似乎不是这样。9 S& O1 T. ~& {) ]. D L
' h4 U1 U; s- O8 [
假设所有符合条件的有 5 笔: Z0 O+ n+ r/ @, P& {) }. L
有时候回传 1 笔,有时回传 3 笔,是不固定的
% V) \1 s" I1 H( k回头查语法定义5 W6 E4 N# a5 ]% L2 v" W N' Z, p
with
7 _- l1 Z5 G2 xagentset with [reporter]
`7 o$ s( H8 C1 }) hTakes 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.
/ P% Z% w. \0 o! Y, Y它只说回传 agents satisfying the given condition% e9 E( ]5 G4 L7 }# N+ r# B/ A1 H
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
% y) a6 z) T1 y+ P* y
; p6 d9 H: n0 |. k想确定一下
* A. ], k6 ~( E% \1 K4 H: {( X谢谢!
! ^! ^7 m3 A* l1 o+ T |
|