|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序! {% C( m) o6 I- c" c M1 C# g: h
其中有一段如下& G# C' j! q5 N" r2 P) h6 M
ask turtles with [ infected? = true ] : i& |! s: A8 U5 ^8 H' A
我原本以为这句会回传『所有』infected? = true 的 turtle
! W/ u: E" S6 Q但看结果似乎不是这样。* @& e4 f8 i H* s r9 G5 {8 e: z
& e" f# V' E4 q5 T4 R假设所有符合条件的有 5 笔1 _% b# ]5 O' G' ^6 T
有时候回传 1 笔,有时回传 3 笔,是不固定的4 ^; _! S5 `, K' Z2 N9 I8 }
回头查语法定义- b: o) ?8 G5 I* L2 a L
with
- O4 y# C( q; X* {agentset with [reporter]9 U9 q9 i' T# F4 S
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.: h4 o* r# o" }8 r0 ^, N6 s
它只说回传 agents satisfying the given condition
4 d+ b, w: U& g- ~; S+ G( @0 g0 F* y是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? : O0 @! x1 P( [: I! ^/ L6 ] A
. J8 x$ M& K6 e, e- C( Z
想确定一下
, a+ i$ s0 F3 b* S6 S3 X谢谢!; v+ F4 w, J0 T- [
|
|