|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
9 X/ |! T! {% }# ?& B- \4 N% o其中有一段如下' O c, L: j, H& @' I. J
ask turtles with [ infected? = true ] 0 c5 I4 G0 P* R( s+ H
我原本以为这句会回传『所有』infected? = true 的 turtle1 s2 j* z* x2 t0 D
但看结果似乎不是这样。
' ^- q2 t/ L, ]: M6 D- _& b. q. b e. A! N+ W/ H9 {# a
假设所有符合条件的有 5 笔
7 [( U6 I% @3 Q有时候回传 1 笔,有时回传 3 笔,是不固定的1 Z. D& |$ m- l z# g
回头查语法定义
- A/ D, \ e+ a3 cwith
5 N! v6 X& H) [, Z+ z5 {& ~agentset with [reporter]. r7 M% Z, q5 [7 q g, @
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.) {3 `' r6 e+ |' U; e' c
它只说回传 agents satisfying the given condition: T/ z9 J3 t$ U0 v$ L6 _
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
. c( V/ C" {9 F* _# l! M4 r3 c
想确定一下
2 W; Z4 n$ |7 `6 K$ x$ f! [谢谢!
1 f% |7 y/ o3 Q5 Z) @ |
|