|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序# e0 n, I' x1 L# K: K
其中有一段如下7 ~: Q5 p# b+ _5 F6 i
ask turtles with [ infected? = true ] 0 s+ k6 k: V# {. E
我原本以为这句会回传『所有』infected? = true 的 turtle
* [* @4 G: ?$ B1 G2 I v1 O但看结果似乎不是这样。' k* k; L0 B2 a1 D4 j' G/ I
v4 D- n( n v7 }" {2 Q% o, \4 p3 c
假设所有符合条件的有 5 笔; U+ [: R0 s2 M6 Z2 \) ?) Z
有时候回传 1 笔,有时回传 3 笔,是不固定的
$ q+ D; \: Y2 R. V' g' G, L5 ~回头查语法定义; ^0 O3 `; y- N) K
with 3 w( I0 t! L1 j! X- o
agentset with [reporter]2 ^+ \3 l& ~: W* z* T! W9 o
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.! W% ~) F( z4 o( t" ]4 z1 M
它只说回传 agents satisfying the given condition8 u$ X7 ?- G& @3 ^* n
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
8 P2 i, ^8 b) F. A( e+ F! g. w5 v+ b
3 R2 \" s: ^% |8 R4 c" {& ]+ m想确定一下
y/ b& Q6 E, M; Z/ I9 Z谢谢!
3 x) P' V. J- d9 [/ z |
|