|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序- U- O* s" t# u2 i: ], P! ^
其中有一段如下9 f# j. h' Y2 }! W j. r3 \
ask turtles with [ infected? = true ] ( g$ [2 K& t0 L9 l9 i1 G* n
我原本以为这句会回传『所有』infected? = true 的 turtle: f/ B/ v0 U/ S7 z
但看结果似乎不是这样。
; m& }# T$ H* k5 p& `% z3 t$ B' z! Z' v
假设所有符合条件的有 5 笔
4 H0 W8 q3 p8 |2 B8 R5 b B2 `5 f8 d有时候回传 1 笔,有时回传 3 笔,是不固定的
& L5 I. F7 a/ H1 b+ T0 K回头查语法定义 w+ x7 @" Z9 |
with & }/ m& }. e) B- A! {% n6 O. b5 [
agentset with [reporter]) G. {2 Z0 h/ A. V) S1 `, a# c1 a( 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.
4 C1 G, K3 C5 [/ x: `它只说回传 agents satisfying the given condition M, a! g4 J6 k r5 z% _
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 4 o+ t9 Z5 H: J4 Y7 w
# m" w7 M3 r3 a' @. n
想确定一下
, y i, m& T0 |; ?谢谢!
5 }3 k0 X/ z; A |
|