|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序' r$ G }3 ~' v1 J2 w. Q
其中有一段如下 w' A0 w5 R `# O
ask turtles with [ infected? = true ]
, B% V1 {4 \, u1 C+ W5 a* V/ C, Q) a我原本以为这句会回传『所有』infected? = true 的 turtle
4 c2 x4 S6 W: G6 @" D但看结果似乎不是这样。
9 M% K) {* E. X! C3 S8 @; I) E+ \/ K1 N4 H+ b
假设所有符合条件的有 5 笔
2 t9 c* r8 ^ j" I- Q有时候回传 1 笔,有时回传 3 笔,是不固定的0 ]. z1 }4 ^. K, i [8 O S
回头查语法定义, U, K- Y' V/ |) b# y9 j
with
- N9 G. d$ S6 w- q9 X2 K, F5 [0 ^agentset with [reporter]( H) W8 P) P3 W" @% X8 {7 _( s
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.
+ f" _. u6 a0 }9 y2 C8 W6 |: A8 T它只说回传 agents satisfying the given condition d7 e3 N; v0 v( W
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
0 N$ ]1 G6 V" q$ }9 J0 N( Y6 E4 u J) u1 s ~ @: H
想确定一下( D* h3 C: ]1 L: \$ }
谢谢!
" @1 V0 {) X W# U1 _6 b |
|