|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序" D% Z5 {" O; _; G
其中有一段如下) P5 c- H) j$ |8 d0 G' c) g' K
ask turtles with [ infected? = true ] + @2 l6 ]% r% h. }2 z2 u0 }
我原本以为这句会回传『所有』infected? = true 的 turtle
$ |; d9 A5 [ A) T/ j但看结果似乎不是这样。5 [7 O( T `/ O9 y" T* w
: T1 ~6 \. e* d5 s I
假设所有符合条件的有 5 笔3 d b; P6 h$ ?" O% T/ u
有时候回传 1 笔,有时回传 3 笔,是不固定的
) I7 E9 b( A: V' `- b7 \& w回头查语法定义
: a" k) v; a. O+ O0 I& z0 Swith
`7 G, J( B. j0 f' b- I8 Fagentset with [reporter]0 N8 z+ V; M2 B' j
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.
) b/ d# }. p/ h0 B它只说回传 agents satisfying the given condition
/ X! s- j/ q; V3 }$ r' D9 ]& R是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? # ^# T" T* x ^: f g9 z M* N
8 R( n2 y9 u7 {1 B* j, y
想确定一下
9 R1 w0 F8 u" U6 n: I) \谢谢!! K3 S2 R+ d' V6 E
|
|