|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
( w. i! y, A2 n; G8 T- E$ ?- k h其中有一段如下
1 g! @( y' o8 [5 z' N' ^ask turtles with [ infected? = true ] 5 V0 S) V# k9 h& |4 x
我原本以为这句会回传『所有』infected? = true 的 turtle/ k4 G! h2 P$ D8 s1 @
但看结果似乎不是这样。- E: E8 S! y/ C9 V: j8 q4 P0 b# ?
6 Q0 _% D& l/ I2 @. x" ^0 y
假设所有符合条件的有 5 笔0 u( V0 D+ x2 u2 Q
有时候回传 1 笔,有时回传 3 笔,是不固定的7 U$ A3 E2 S4 ?1 v& O4 d$ g0 }# d
回头查语法定义
0 C% H& Y3 U+ {/ K+ N8 o; m' |with
# G6 ]$ V8 d; `" V gagentset with [reporter]
. @6 h) t% c# B5 H+ v( Q7 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.
/ b6 V9 ^, Z5 r' o+ o/ ^% [它只说回传 agents satisfying the given condition
- S4 E1 U* ^/ o* a- J5 w9 a# u是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
2 X& |% O8 h9 q% W$ I0 @6 w$ j. i7 Y3 ^! N, [& x8 \
想确定一下
" P g7 F* N; a谢谢!7 V" K. \: v& e! x6 u
|
|