|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序1 |7 M w% B! @" [+ h. W' u" b+ d' u
其中有一段如下) Z1 s6 F9 b, J$ I7 D0 c) g% D3 S1 X
ask turtles with [ infected? = true ] 6 m+ l+ b( r$ M( K1 b. m5 ^
我原本以为这句会回传『所有』infected? = true 的 turtle5 e5 d9 h2 S. }. p. k& j
但看结果似乎不是这样。
$ z& D- L: g2 w* r8 X
2 ?3 u" `- b3 O3 Y/ @# b m# O假设所有符合条件的有 5 笔
' { e4 q4 z u; g" @有时候回传 1 笔,有时回传 3 笔,是不固定的
1 s- o( }/ Z% J& V回头查语法定义
' w+ Q# G& o% ywith
" u- |/ \( E* S8 X! k6 uagentset with [reporter]
' n# z7 p8 n# f- T' T3 I; F, y8 QTakes 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.# n6 J- y2 I' W4 x& n7 s' l# h
它只说回传 agents satisfying the given condition
2 w5 ?/ d ~+ }9 k( ~% L, k是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 4 I6 R. |* p, u1 S/ d
/ O% T; d& j: _0 b* a$ {想确定一下
j) Z# q+ [; S; ^5 k" {谢谢!
/ L( s5 A& _! E# n* u: t$ l6 G |
|