|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
$ a6 { g9 u. K* c5 E5 a) E2 O% D其中有一段如下: |. O. C6 k8 Z6 `1 I3 I- [
ask turtles with [ infected? = true ] : E' {% A9 | j0 m$ o6 X
我原本以为这句会回传『所有』infected? = true 的 turtle
0 Z6 e1 Y5 \% E但看结果似乎不是这样。8 V4 g1 N0 T! A6 K$ J. H: s8 [% c7 b2 k
; Y' I6 P3 ~ @( B3 S8 W
假设所有符合条件的有 5 笔7 U, Q! Z% u6 E! D" Z4 B/ U7 v# c9 W
有时候回传 1 笔,有时回传 3 笔,是不固定的
6 h% F0 m0 H% g' p回头查语法定义! F* x/ ~9 F% U: n+ F6 C
with ; [# D3 R O* M. ~9 ^3 K$ H
agentset with [reporter]. X4 {) N. u% U" o# H$ W, Y
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.
1 L) R' {. a4 Y" h它只说回传 agents satisfying the given condition$ ], V n V/ ]; F6 Q4 H
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? ' s6 H1 s0 w$ _ q9 w; g: W# D
3 Z1 n1 g, ^! J# d5 I, ?
想确定一下" D) s9 c# J! G) V
谢谢!; X. V s+ o7 m- O7 R
|
|