|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序: A- w; g a9 [7 E* |# q8 b
其中有一段如下1 A+ ^! ^! h) h1 R/ y/ U
ask turtles with [ infected? = true ] 7 P$ r6 K% ~6 L# h$ ? e% P
我原本以为这句会回传『所有』infected? = true 的 turtle% v; ?2 U, z% ~: ?) r
但看结果似乎不是这样。
1 w2 |+ n/ ?2 P: r% u, t
/ m! r. b& S; U( B3 E假设所有符合条件的有 5 笔
% f8 `2 c$ Q' d4 m0 l有时候回传 1 笔,有时回传 3 笔,是不固定的% H- N1 ?5 E- l" r& `' a; N
回头查语法定义
& H) N5 c, F; c+ F; l' I8 vwith ( t1 W' h! F4 ^- L$ Q7 b2 O1 V! J
agentset with [reporter]
: p W. f" v; g. s0 [. \1 E' J1 @+ iTakes 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.& C& H5 c0 I5 w1 X& H
它只说回传 agents satisfying the given condition" {. W8 N# |- z, u' k! m( K
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
( r0 ]$ B( U0 N: a2 }' t6 r: W
想确定一下
* \7 k! T& n. o谢谢!
! O% }5 f% U5 l1 G" g1 Q |
|