|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
, D2 r# T% ]9 J2 N/ \* R% T4 W其中有一段如下8 B1 S* ~9 T3 ^# `5 j& a* _
ask turtles with [ infected? = true ] ) f3 \) |, w% i, N, N* Q: r8 r
我原本以为这句会回传『所有』infected? = true 的 turtle/ n; `- |+ x$ e/ A' H; Y0 R
但看结果似乎不是这样。
0 U( `! @+ s5 z! A
! r5 s9 z5 U( C" v假设所有符合条件的有 5 笔8 W8 L, q7 b0 ?* u* w
有时候回传 1 笔,有时回传 3 笔,是不固定的 G' m* `2 |: @4 J0 e
回头查语法定义9 L. r% Y7 Q l. }
with
+ T9 l9 J3 F1 Z$ N% ?, }/ d1 l7 N2 Yagentset with [reporter]/ `8 h: b+ I1 L. }3 b
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." ~2 p0 N7 T; `" o
它只说回传 agents satisfying the given condition1 e& u' _! Z3 \4 t: o) [
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
% @' S* E: o( C3 X/ B5 w2 e0 t% D2 z7 X
想确定一下% C. [2 f5 W6 J: a$ c0 o! U r
谢谢!( y9 ]! {5 a4 V; W9 S
|
|