|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
0 C/ l0 B$ x% T' P4 i# Z x其中有一段如下8 ~) }0 d" l; o! n! }" X/ o
ask turtles with [ infected? = true ]
+ ?# c @" {2 \. v4 I8 R我原本以为这句会回传『所有』infected? = true 的 turtle
- x( v+ U7 e$ Y( u5 Q但看结果似乎不是这样。: O: {+ o# r# ` ?& s
1 S$ ^+ c5 }& O* @) {; g' K5 Y+ V
假设所有符合条件的有 5 笔8 p& n; f* b* ^% |3 T
有时候回传 1 笔,有时回传 3 笔,是不固定的: l0 p a- e. ^! X5 b* Q
回头查语法定义: ]6 S/ {6 G' T5 k* {* f. R: O4 X( u
with
7 e# c; r- G% p/ m3 e0 fagentset with [reporter]
0 ~+ H- @. w4 C: i$ `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 j, p8 e" s# I W# ~8 c7 F: C& L它只说回传 agents satisfying the given condition: T! m; G' T, B* p) y
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? ]& U \' z5 \* A0 D, |7 }: T
2 L* K& \, }! s" F想确定一下; j% W" O0 s7 b% ~& A, Q
谢谢!
: R }# E8 `, M, n& p, V% {2 L% x5 [ |
|