|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
: H2 j- x2 f. y7 \7 h* A# b其中有一段如下! ]3 |( K& q p4 f$ f0 R
ask turtles with [ infected? = true ] ) ]; ]; O% X& G) s
我原本以为这句会回传『所有』infected? = true 的 turtle7 H3 }# e1 C) j: A7 y' J8 y. ^
但看结果似乎不是这样。
+ J# d/ W. V" t' N7 `# C% c4 f& {. F* x# ], L
假设所有符合条件的有 5 笔; C: K& F. C9 Z% D
有时候回传 1 笔,有时回传 3 笔,是不固定的
5 g$ N& N' j6 o2 w回头查语法定义
8 q$ C' @. o. f P$ J) _3 l0 Uwith
) C0 T' J* e- ]9 B. X# Y1 ^ jagentset with [reporter]
) [* L/ B' p; l; v3 c; U1 w: O; kTakes 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.9 v8 a5 N: f" b9 `
它只说回传 agents satisfying the given condition3 t$ l7 k' q7 }# u& f: z4 X, s+ _' ^6 ?
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
: N& N& O/ _) K7 _, {% }: _% q) c+ Z B9 k5 i) r+ T
想确定一下
3 J/ G6 i A) r谢谢!: b; ^7 s/ k7 @
|
|