|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
* |1 S. f$ {+ z; b; Z* z W其中有一段如下5 g) {3 S) T- U5 P* W6 m. Y
ask turtles with [ infected? = true ] ?8 R0 i, k# @+ |& L
我原本以为这句会回传『所有』infected? = true 的 turtle X) v" F; D5 U" v( S+ [/ k$ l/ Q, N
但看结果似乎不是这样。3 x T1 O& |& }. s# V1 e
/ m2 r) F) l0 V! U9 {) v假设所有符合条件的有 5 笔
( ~: T! T; R" Z" z) P Y7 q有时候回传 1 笔,有时回传 3 笔,是不固定的
+ O0 d; _$ X. \# L6 p回头查语法定义
( }+ }, w/ B, a( G9 Z% lwith 5 l7 ~; @2 y& c/ G! {1 c
agentset with [reporter]
- V% l- w1 j& 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.$ u2 w# a3 G! ]5 `5 {& V
它只说回传 agents satisfying the given condition
3 @6 o" z2 F* P; J是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? ! ^7 C. Z* _6 R6 Q# \
* l$ @% l/ P$ w想确定一下1 j4 P2 T# @6 F0 N: `/ X. z" F; p
谢谢!; k$ i$ B4 M$ X; Q2 s8 R: O! J
|
|