|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
" C8 \3 z3 x+ G7 G$ [$ g, j其中有一段如下, X4 {/ ^" b2 g; a
ask turtles with [ infected? = true ] 5 n% J p" J- p( P7 i
我原本以为这句会回传『所有』infected? = true 的 turtle. F( n% j0 S! \- G
但看结果似乎不是这样。
' ~: Z) h, Z6 s" c1 B6 k! e w* ~; R- z; g- |1 G7 m
假设所有符合条件的有 5 笔7 N# q' q% O6 ^+ U
有时候回传 1 笔,有时回传 3 笔,是不固定的. F& P2 r& A5 c u' G7 {2 R
回头查语法定义$ [: X- o8 q1 ~' J# {
with
3 ^+ ]- T/ N8 @- dagentset with [reporter]6 p; f4 ^+ 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.
" h( N* d0 }; q它只说回传 agents satisfying the given condition' }- O- i. `- t; b
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
3 w! w, r6 [( p) m' j$ H
5 Q0 [% ^* P" _1 f0 d4 z8 a. Q想确定一下
/ ]$ f: J4 m6 R4 q3 l谢谢!& H1 S2 U' i/ Q* S7 o' G
|
|