|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
! ^0 x3 c7 W6 g, q) @- e9 ^其中有一段如下
2 E, s2 \5 K5 w3 s4 e7 \7 G) `ask turtles with [ infected? = true ]
+ X8 P9 o" l" q& D2 Y我原本以为这句会回传『所有』infected? = true 的 turtle' Z2 o, A) K1 j9 c5 P. _
但看结果似乎不是这样。
) F9 P9 N8 U: K/ S- l; ~' u3 l, b+ X/ C, q: Q/ Z% ~
假设所有符合条件的有 5 笔
* T! b3 ^7 {% O3 \有时候回传 1 笔,有时回传 3 笔,是不固定的4 L- k" r) v% i+ t; ]# J
回头查语法定义
# B6 L2 c& e" o) x( Ywith 1 P% W- s3 V4 k2 ?+ F* K7 [2 T
agentset with [reporter]& G; e+ m$ ]5 }3 g* v) k* R4 N
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.1 b# Z/ ]; e( u g* @8 N+ n9 w
它只说回传 agents satisfying the given condition
/ M9 M! G1 y2 @1 I* J是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? R, |/ @4 S8 X$ q6 j+ L, R* [
4 z. B: i/ N U+ Z/ D9 d8 p2 X) a想确定一下
8 _% ^% N* i0 r$ I x2 X D谢谢!; x" a' h/ k, u6 m# w
|
|