|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序& t5 q; ^) M. q2 }3 V7 p
其中有一段如下/ P& i1 d$ k( N6 \: N" `
ask turtles with [ infected? = true ]
9 A% b7 g; A. U# \& N$ q我原本以为这句会回传『所有』infected? = true 的 turtle# d* y; `- B1 E$ Y9 a7 {; c! G6 [
但看结果似乎不是这样。
7 D' o7 T" l3 y3 S$ ~" R {4 K: B& t, L7 V# t2 \0 D" z
假设所有符合条件的有 5 笔3 P: X" ]" i: ?; p8 `! ?# Y& e$ s
有时候回传 1 笔,有时回传 3 笔,是不固定的
& i3 G g+ z; c8 n' a$ j回头查语法定义
! H5 G- t" ?" m/ f8 L% pwith - z* M ? D2 G6 n% f) L8 j
agentset with [reporter]
8 _, o' s2 _. b. I& }) z, }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.
7 a) K$ j- \. ?3 t6 F" ^. \4 I它只说回传 agents satisfying the given condition7 ?8 v1 U% }+ Z( o
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
9 u, H/ ~ ^+ K* I9 b5 H' X7 v: A" Q! \( ]4 r. o a: [
想确定一下& G7 i- E7 z7 ?" O2 S$ F1 Z
谢谢!* F) U% [0 ^& a
|
|