|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序5 n% u; Q4 y, l/ u) S" \
其中有一段如下2 H8 E$ ^+ {$ A% O# r! R/ y
ask turtles with [ infected? = true ]
& A) s8 O, i6 k9 [我原本以为这句会回传『所有』infected? = true 的 turtle
8 r4 R( f8 |% D2 u# o0 Q% I但看结果似乎不是这样。2 b2 a8 j, W2 t( `
& ?; b* v) ]* u6 p假设所有符合条件的有 5 笔. h A, ]. G' J. o1 P: u* S: O: S
有时候回传 1 笔,有时回传 3 笔,是不固定的( R" R, f* C6 q. |
回头查语法定义
; _3 X4 o" P$ w' r- Q$ ]' [with
* H6 G! ^6 M, F+ w' G* c9 Qagentset with [reporter]) Q" ]' W3 M: e1 Q
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.
& {3 T1 u/ r( P* |% u它只说回传 agents satisfying the given condition2 c* v M8 `6 p3 u! S- W$ v
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? ; F) J. y) _9 |' y/ y. N; ? n+ }
# i" c3 j, I$ x+ R8 _
想确定一下
% I& V% [# e. Z$ s4 M G+ I谢谢!" @/ S, }' u9 p3 ?1 I0 h
|
|