|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
; {+ J; X) B% k- x) F其中有一段如下2 q- E) Q; M; L6 s& @4 p
ask turtles with [ infected? = true ] : T& r% w. H0 U, M& Q0 u: u1 \% e/ y
我原本以为这句会回传『所有』infected? = true 的 turtle* G" J& y. ~- G! n* A+ z, _
但看结果似乎不是这样。, O" w$ V% v0 }8 k0 a
7 v2 D I% m( t9 ?
假设所有符合条件的有 5 笔
' K' P) E' [9 K/ k2 ^有时候回传 1 笔,有时回传 3 笔,是不固定的0 g( G$ R/ R: n, f! \
回头查语法定义8 V. ^1 D4 W9 G; c9 c6 s- z
with & c) H1 U: T H8 K' \! d
agentset with [reporter]
( {0 Y/ r; a+ {. Q" ZTakes 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.( ?+ g1 {! t+ ~/ e
它只说回传 agents satisfying the given condition
6 I, c" X9 `# G" G: ~) O8 v2 |是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
# Y0 q& D' `! F N) l$ C: g( c' B) {: i
想确定一下
/ y1 N9 m( R r/ s9 I9 t9 t谢谢!
" ~: i8 _- ]6 Q |
|