|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序2 V" T" P6 J5 j9 n' K6 X( u+ y, J
其中有一段如下
" j: r2 ]& B& t2 E+ f3 cask turtles with [ infected? = true ] $ U* A, a, C$ M1 Y# e* h( _
我原本以为这句会回传『所有』infected? = true 的 turtle( \, P- s, f1 m- u4 |9 W6 k
但看结果似乎不是这样。
/ I6 }: T% f+ Z8 r8 G
2 g0 U$ \) _4 U6 R+ G假设所有符合条件的有 5 笔
6 j( E) j8 ~& f- ^有时候回传 1 笔,有时回传 3 笔,是不固定的
* P0 b- j( S* C* A' s( Y回头查语法定义) ]! Q7 @/ A: l ?! L
with ( t% J) @( Q Z' V; A3 ^ t) [
agentset with [reporter]- y5 q% F8 B6 A6 \9 p
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.# y- Z. ?5 [$ x
它只说回传 agents satisfying the given condition
* ~7 u0 J5 M& g1 Q. V+ I: ]是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
3 d5 H* j0 @4 F/ r- a- \% p" C& Z9 W& `, ?3 l
想确定一下
% q# E3 ]3 B% _! b' _6 G谢谢!
3 R: w! ]' p. P8 s |
|