|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序. N/ c, N8 X: R0 ~2 S
其中有一段如下7 W. Y' O3 X3 [
ask turtles with [ infected? = true ] 2 e# L1 Z& b' a7 C, _/ y
我原本以为这句会回传『所有』infected? = true 的 turtle o: K9 u v& M l$ v% @
但看结果似乎不是这样。
8 t, T8 ] X9 m Y! E1 ]; [
8 Q1 n1 ?/ s( w. F( v3 z$ D& \假设所有符合条件的有 5 笔% ?' q, Y. {5 a' Q8 [
有时候回传 1 笔,有时回传 3 笔,是不固定的
+ ^" L9 E q" J; q4 E- H1 E1 S+ w& s回头查语法定义
' {( E; A9 s9 G/ `1 g1 Ywith
! C- e( g" T- q% |, Dagentset with [reporter]. N0 O) j! ?; r7 H2 o- A k0 x6 [
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.
|# b3 j/ }9 d它只说回传 agents satisfying the given condition
0 o. X6 E& \2 j8 ~是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
- [4 S4 p' |* S0 k: _
P* }% N0 V% `% c2 T4 U/ s2 C+ R想确定一下: _) \$ j% s0 ~$ n, g/ A
谢谢!
5 |8 X% j( s5 F% h |
|