|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序" W8 E6 X, N V- T2 G
其中有一段如下, x% ]$ c: ]( d
ask turtles with [ infected? = true ] 8 u! B5 K8 R; O9 |1 a8 U
我原本以为这句会回传『所有』infected? = true 的 turtle1 [& ~, ]" o& p: D/ \* `3 G
但看结果似乎不是这样。" g; |3 j$ S) U5 C. [: t
5 \8 w/ P; h6 X1 v. o/ F+ q% w, w
假设所有符合条件的有 5 笔
, M. u4 k3 Q7 D6 ~. L有时候回传 1 笔,有时回传 3 笔,是不固定的) M! L! m ^. V }
回头查语法定义6 J6 b: K& W' c8 k7 y
with
- n% N4 ?' n! t/ b' uagentset with [reporter]
' ?0 `, ?4 v* m0 j' c: [. wTakes 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.- o# J' d- [1 U5 k1 I4 a
它只说回传 agents satisfying the given condition
2 l/ l9 D8 i1 X/ ~是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
1 N3 v6 g, E3 w8 ~3 K
2 M1 c. x2 q7 _6 B1 w6 \5 T6 _想确定一下
$ n* |, x/ {; Q' d" C谢谢!
9 Y4 q. ]2 y8 |. @1 e& c* M |
|