|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序1 P( c& [0 u2 g! d$ g# e- W5 I
其中有一段如下* S8 W# C) F1 J! [, R) ^
ask turtles with [ infected? = true ]
: T$ A: V: k8 E我原本以为这句会回传『所有』infected? = true 的 turtle
3 b9 Y L5 a1 k但看结果似乎不是这样。4 w+ }- G$ R/ }4 C2 g: `$ u2 t0 U
. W& f: P) F4 u( W假设所有符合条件的有 5 笔- s* j% }* F, }* S) [- I
有时候回传 1 笔,有时回传 3 笔,是不固定的
O2 h1 M! K) w6 u, s+ N, I) _7 l4 K回头查语法定义
* k8 j. i, e6 u Y1 rwith
; v9 d, G8 f( I; [+ L5 S( ^& wagentset with [reporter]3 g# M1 l7 m$ H# H8 X
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.
# `5 K& a$ t, m# c0 K0 @它只说回传 agents satisfying the given condition2 `6 C7 F1 J: m8 U" U. y
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
/ L3 `9 m6 Q: W3 ] ~8 [: x$ v4 o, `4 h. C M2 i) U
想确定一下
- N0 Q& m0 R. r# l5 E, p谢谢!; x6 F* B) ]4 ~4 m3 [/ X
|
|