|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序+ n! _6 u$ S S; V K$ R8 ^& `
其中有一段如下* b K$ ^( }. j0 p. Y1 J( L
ask turtles with [ infected? = true ] " P4 R1 W; P3 A" [
我原本以为这句会回传『所有』infected? = true 的 turtle
+ i0 z) Q6 W* I6 B但看结果似乎不是这样。
2 M& Z- g' Z5 \5 Z7 x: r3 M5 ~8 ~( O9 K
假设所有符合条件的有 5 笔
2 S4 B7 R& f$ ]# c有时候回传 1 笔,有时回传 3 笔,是不固定的/ ?. ]) _: U0 B* P4 A" m# |
回头查语法定义
8 V) k0 _0 T& M& B9 mwith 8 w( n& f% M5 L- k& z, {
agentset with [reporter]. j3 r8 u( O$ V/ ?5 i
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.) a) {. K% P+ u
它只说回传 agents satisfying the given condition
8 `" ~) ~7 M9 E1 W( f5 L是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? ) u2 N2 m y) P; J: Q% z
! z. M) j- b6 K) R( `想确定一下
. U' o# K8 A8 z" [谢谢!5 p6 X! M8 m, F; d2 M; v3 y/ D
|
|