|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
& `! H, @& I5 T; g; h k7 K P. {其中有一段如下
2 e' y+ ^& x4 F0 @2 [# }ask turtles with [ infected? = true ] , w9 Q; o5 X# {" L) q
我原本以为这句会回传『所有』infected? = true 的 turtle
9 L3 ~' o: E. W* O9 v- T但看结果似乎不是这样。, ]* i# B2 E; a3 H- L7 a
; y8 r, m/ _2 W" f7 Z3 @ l' F( c
假设所有符合条件的有 5 笔
! b- c& r7 P- Y+ ]有时候回传 1 笔,有时回传 3 笔,是不固定的9 r' C& l$ p& q$ V6 S6 F
回头查语法定义6 R; m/ s- e% i/ X E8 x
with
+ C6 r2 g; K) _! Q4 Uagentset with [reporter]
% T8 g* t/ O( K3 `( rTakes 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.! t9 U4 e! j7 ^% o- @9 E
它只说回传 agents satisfying the given condition8 E: G. @# a& ? r) y& }
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
; l$ |4 B$ R0 {& n; G4 D$ z2 G/ `* I o; g& Y) c/ `5 }
想确定一下
C) a; m7 y$ F2 T) h& b谢谢!! P* b: \$ E) v: ^3 z
|
|