|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
& y4 d# |. {- X) z+ Z; w. V( l其中有一段如下9 r. K X- |/ \# D6 T% O* b
ask turtles with [ infected? = true ]
2 I; P& c6 d( \ B$ F4 F我原本以为这句会回传『所有』infected? = true 的 turtle
1 {3 @' a6 x+ b) z3 O但看结果似乎不是这样。; F' e7 q; Z9 f2 ?; T2 g9 V
, b3 z0 Y0 W9 ?7 y- q3 e& \2 E假设所有符合条件的有 5 笔1 [ h# `( w, H6 q. q3 C6 x3 b
有时候回传 1 笔,有时回传 3 笔,是不固定的" V# S K/ I& Z- X$ A
回头查语法定义% G" l) Q4 S2 k- Z7 ^$ p
with
1 J+ n9 J/ \, O5 \. Y; U+ Magentset with [reporter]; D! K! {: t7 _1 u
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 P+ ?( A3 l! U# A( p- r, ?1 E
它只说回传 agents satisfying the given condition k. i& t1 @7 ~. l& e' V* F# s
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
0 C4 c; o# k, K, v
$ D! n1 v, ?# d想确定一下
+ e( Q$ V/ p! w5 c& ]) k# U谢谢!4 ^6 b9 V' v4 w8 I) N) y% {" e) }
|
|