|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序% N% r0 f3 L t& a
其中有一段如下& o$ u0 T* V: w8 k+ i9 C w# z
ask turtles with [ infected? = true ] ; U+ }# p% z7 W
我原本以为这句会回传『所有』infected? = true 的 turtle! \( V7 i) p$ }+ ]( ? V
但看结果似乎不是这样。
* `3 ^) r2 }0 n7 Q* _! S" K; F6 s5 {4 G# z! \, w
假设所有符合条件的有 5 笔
N0 K' `' |* j有时候回传 1 笔,有时回传 3 笔,是不固定的8 y8 Y) K E6 _$ ~: ]
回头查语法定义6 A7 L5 L2 ^4 t, Q4 i
with
# ]% ` U; j& z& }* A- ]$ \, B4 E% N2 Wagentset with [reporter]
$ M; ~, c& e" }" S% }7 I; i9 TTakes 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.. ^& b4 e4 G' J6 H" y) t+ \' C! J
它只说回传 agents satisfying the given condition
; d: |: D& Q5 F* u" i& D是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
! L; S% z+ W/ L8 C8 M& R; m8 m$ c1 B
想确定一下
! n6 m% _* I9 ]! x, `3 a: h谢谢!
% J( h# K5 A, f |
|