|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序( v$ E+ J3 j4 k T8 S1 Z, C
其中有一段如下
* Y/ a/ J; X" ]' P# V5 _. u7 Yask turtles with [ infected? = true ] * ~7 j: [$ m% v1 Y4 S) b6 M
我原本以为这句会回传『所有』infected? = true 的 turtle4 k G5 o- W/ D3 J+ N/ c( f7 l/ z6 k
但看结果似乎不是这样。/ U% q! P% x; c& N8 i
' E# N4 A; s2 a, w" R0 S
假设所有符合条件的有 5 笔
4 V. X" _. K& b7 }0 _& b8 D3 T有时候回传 1 笔,有时回传 3 笔,是不固定的3 w8 J. t- J) V, {9 G! R6 q/ d+ r
回头查语法定义7 z, y5 Z) S$ h1 }
with : M/ T3 ~5 t7 t8 o
agentset with [reporter]; v% ~3 D7 Y# @4 L7 r# C
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.% d' p8 E7 L) U% J
它只说回传 agents satisfying the given condition3 k1 P+ a' l, C/ K1 H& g% C; t
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
& [+ f& G7 x; o' W. ^6 V" Y( S. \& U( o# J/ H/ G% M9 l
想确定一下
; h$ n- r) J' z6 H" ~谢谢!
% Q" c4 @7 X2 S, p. w/ e1 T |
|