|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
9 X3 K6 X2 K/ \+ y7 [1 G其中有一段如下
1 H$ _7 H, v$ E' y9 Xask turtles with [ infected? = true ] : ~2 z! u* L1 r( E! Q0 @& [6 ]
我原本以为这句会回传『所有』infected? = true 的 turtle
' p. c! q6 M" J/ @' h6 d) r但看结果似乎不是这样。7 @' t" G; J0 q: ^/ R
0 ~) g, J7 ^, O, y1 S0 y; b假设所有符合条件的有 5 笔
, {/ i3 R- V( M( W有时候回传 1 笔,有时回传 3 笔,是不固定的: k$ `9 Z6 g/ C* p1 e* i
回头查语法定义, [6 O( e7 h) H7 o& R! F, v
with + H* X1 I% S' N/ F$ a9 S( i) p
agentset with [reporter]
) h& |* X5 w4 u( q8 yTakes 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.) t8 r* o5 m8 z
它只说回传 agents satisfying the given condition( N" u% [' k7 D
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? " m# v& R( u: [3 C
. w. E' \' E' l想确定一下
; e5 m0 y" K2 U0 v/ F. y$ i+ K谢谢!
- L: D0 `- \1 w* \ |
|