|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序3 \" A9 K7 W$ H* G& x
其中有一段如下& n6 r0 n0 E+ J5 H R" x7 q3 w$ |
ask turtles with [ infected? = true ]
4 R7 q& o1 I% z2 `3 C& h/ _我原本以为这句会回传『所有』infected? = true 的 turtle
' U0 b5 e5 _/ c6 K1 e/ D% X但看结果似乎不是这样。
Y, o( D% e9 a0 |& h6 v5 r# z7 y
% K4 ]. L2 G1 W7 u. l9 j \4 ~假设所有符合条件的有 5 笔0 n3 H; @& [; e# A3 _
有时候回传 1 笔,有时回传 3 笔,是不固定的
( x; L8 E& Z7 D回头查语法定义$ D9 e* o' u& I ^
with
/ o7 j! s f! N. c4 uagentset with [reporter]4 o- _+ a: h j8 Y5 z: X4 H/ W
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.
! V- V$ _- H0 R4 H% Z$ Q" b% U- R它只说回传 agents satisfying the given condition7 |( {3 t% o2 s; I5 o! d
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 6 ~ H: L0 K2 B7 \/ e
" y6 S- e5 F# Q+ Z想确定一下0 F: O( p- W9 K) w
谢谢!0 B1 p7 E9 w; C' {* p, X" @
|
|