|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
9 y. u6 l: T8 G, v$ |1 [; k其中有一段如下4 Q& O* t6 h% Q2 h
ask turtles with [ infected? = true ] 2 n: I7 o- Y: N& t2 _8 T! M
我原本以为这句会回传『所有』infected? = true 的 turtle, E; r+ u! }: q; _4 L9 V, H
但看结果似乎不是这样。# y& L% _0 N0 B2 e/ k9 j
; i3 [$ W% s! N假设所有符合条件的有 5 笔
. C# z2 ?( R. a/ J D$ D O7 P, w有时候回传 1 笔,有时回传 3 笔,是不固定的7 d' e! S6 @! j! v; {; j( u* x5 Y$ m* f
回头查语法定义
. ^! {! y; _% R* {. u2 qwith ' N) w C/ z$ }% k) t! p1 E, o
agentset with [reporter]! j2 E8 n7 |- D2 L" e$ ~ F, F
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.
4 G8 w) b% W% i9 O' d9 y它只说回传 agents satisfying the given condition+ o/ @) W/ L( R7 Y( ^
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
5 x5 I' d0 Y: ]8 a! H, x
2 b+ V* Q0 y! L/ M想确定一下
5 s3 F# ^" Z0 A5 W; p谢谢!$ d( ]- c a& o. y$ l- k* b
|
|