|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序% ]! Q2 l# k* W6 B% X' s0 |( [
其中有一段如下+ \2 O6 x6 @+ Y a
ask turtles with [ infected? = true ] % h+ y1 R4 d0 q8 s2 U6 Z" p0 R
我原本以为这句会回传『所有』infected? = true 的 turtle/ s+ j* x+ ~, q+ z% l. j; G
但看结果似乎不是这样。
4 N: L8 c& b6 ]" w+ y# w, G: S* S. w7 g, f/ ]+ Y
假设所有符合条件的有 5 笔
' t7 f5 I* j+ M/ R4 n有时候回传 1 笔,有时回传 3 笔,是不固定的
+ N9 C" g- R5 h# a回头查语法定义
7 K9 f3 b! q8 n( O7 `* S6 h9 ~3 ?with ; C& ?7 H. M3 d* E7 Q" p! s: e8 p
agentset with [reporter]" X, }8 @" J7 }0 l& f
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.8 q. g1 R+ ]6 a' T: m
它只说回传 agents satisfying the given condition
0 x$ Z3 R+ ?8 X; x; Y6 M是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 9 H C4 h @" y. Y+ W. E; @0 p
' R: B6 \: Y8 \: d9 m想确定一下9 s+ h. G" F v R/ R( R
谢谢!
" }7 F+ h) r4 k |
|