|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序6 b1 i. d- {+ F* \/ s! G
其中有一段如下8 ~ |- R& |. P0 d9 R! Z
ask turtles with [ infected? = true ] 7 h x6 J: j$ |7 K6 J$ H
我原本以为这句会回传『所有』infected? = true 的 turtle- ]# u, Z3 `0 `" }% k* u
但看结果似乎不是这样。
7 C8 X( G! Z1 T0 j' E
8 u! F% W# Z4 ^. X假设所有符合条件的有 5 笔
* Q# L, X* O+ @' e9 i5 r& }9 b4 t有时候回传 1 笔,有时回传 3 笔,是不固定的7 h, w/ k% Y& i% n+ l$ S0 m2 r% _
回头查语法定义$ j5 B0 T( x0 c4 X/ w) O. c
with
3 s6 m2 i8 o0 |4 T$ u m7 iagentset with [reporter]. |4 O6 _( _( p2 M% G) L
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.* [2 t" R/ {4 f
它只说回传 agents satisfying the given condition
, y* t! T" d. B& P是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
5 k' |! Z4 B6 z+ F) j r% Y* n# Y7 [/ m9 ^4 N: o* h4 t8 `
想确定一下5 @4 A% c/ p J2 O
谢谢!4 Y' n& o2 B( ]7 t, B
|
|