|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
3 W: N4 t6 {* p( o V4 h其中有一段如下% ^0 S$ K C) ~ Z; {+ c- U
ask turtles with [ infected? = true ]
( h0 {" g+ P1 v4 \) M0 `& O4 Y我原本以为这句会回传『所有』infected? = true 的 turtle% o: _- I) Z/ C( G6 b
但看结果似乎不是这样。
( G) h9 u: y. N& m6 M
: x2 c, |% ^8 b. U4 ]4 Q2 j假设所有符合条件的有 5 笔
0 @3 Q6 E, g( p! f有时候回传 1 笔,有时回传 3 笔,是不固定的) h* w& @: h# x4 ^% v2 N5 f3 z4 f/ j" T5 I
回头查语法定义
6 U7 M% d; q( J i5 Awith
2 B# i1 d+ X7 wagentset with [reporter]! |: G+ l3 |7 e2 D7 E$ t
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. f/ p0 k1 V2 ~8 h
它只说回传 agents satisfying the given condition( K7 C: E( A$ k4 q: ]# Y
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
2 _; Y- J9 j( c$ P0 v5 v8 p( K8 {
想确定一下
! p, ?" A7 u K3 m* k/ w谢谢!
+ M& m, C7 F o; l% ?) j |
|