|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
0 R& r3 Y% y9 z6 g" A/ k其中有一段如下- e, s, k0 l/ S5 R- x l) o- K& c
ask turtles with [ infected? = true ] , v, _5 k" e" L' K' i
我原本以为这句会回传『所有』infected? = true 的 turtle5 F4 L" c- ~$ e L
但看结果似乎不是这样。4 n6 p. _ L. h6 R1 ^9 \8 S7 u2 T
4 s: K! ^$ X4 }8 E4 _9 t: T4 f: X/ R4 b假设所有符合条件的有 5 笔* S* X9 l. A: \7 y# v) Y+ o
有时候回传 1 笔,有时回传 3 笔,是不固定的
- S4 g, d" ^" ^- h. ?1 I; I1 c' b回头查语法定义1 r+ E# ^) d+ o4 G: s
with
0 _! v2 `- x8 I, n7 M2 o5 f/ W) Oagentset with [reporter]
1 N' `& ?- o: w# D( e) aTakes 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.
) Z/ V% H$ L6 `* D: ?+ D它只说回传 agents satisfying the given condition2 o5 m U: c `5 o5 F
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 9 v& e6 F2 F3 p- S! Y" K( @* L; P# t
( [( `6 @( l& `% H2 n
想确定一下
3 G( T& L3 E/ U" l( }% i5 {谢谢!
4 V4 B# g$ u u2 Y4 ?; v |
|