|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
% B( P& h2 S+ E8 D: J其中有一段如下0 d5 m% C+ \9 ]3 v) h9 E6 L# o2 O
ask turtles with [ infected? = true ] % ^+ {/ R7 Y- b' D
我原本以为这句会回传『所有』infected? = true 的 turtle
2 V, ~' m6 W3 C但看结果似乎不是这样。
. N( E% w( u x+ J9 y+ a- Q& _
6 Y7 g# q2 c" G: A/ t4 [% ^假设所有符合条件的有 5 笔9 |/ ^. ?& J. M, l4 J) T
有时候回传 1 笔,有时回传 3 笔,是不固定的
3 W+ F- w9 E% Z8 b; h( x) F/ k回头查语法定义6 P/ H( b- B% x% a
with
& `* T' H" e4 `" G6 Hagentset with [reporter]
! c4 e9 t) Y9 l) [* I! Y, 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.
) h, Z+ r3 s' g8 `* y1 M) K它只说回传 agents satisfying the given condition
) U! k! H5 c# y7 m' }是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
9 u2 W5 u5 \, y6 G0 b1 M# K1 @! u7 x% L' w( z; |
想确定一下1 o/ s* F7 T& ?
谢谢!
$ F; J0 h8 ?. Z5 w+ S9 e: l |
|