|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
8 D5 T8 m( D' g8 w1 b其中有一段如下
0 m, c6 W6 z1 p" T1 x% c+ X5 S. \ask turtles with [ infected? = true ]
* o# W/ S) x) A我原本以为这句会回传『所有』infected? = true 的 turtle
7 d6 B% k2 H; H但看结果似乎不是这样。 x8 s9 H" d6 i5 T8 l( {! M& n
+ c7 F% T# {2 S6 n, p* c假设所有符合条件的有 5 笔
5 ^# }9 M" N: r; _$ J9 ?. y有时候回传 1 笔,有时回传 3 笔,是不固定的
; E3 g" ]+ P: r d* e回头查语法定义7 o+ W; J2 V( j0 M; N# K+ y
with 7 L* e1 P& b. X9 [
agentset with [reporter]4 j( D$ x, n6 r9 m8 u4 M' s+ W
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 s8 U& B: H6 J, ]它只说回传 agents satisfying the given condition# r" V* Z2 g9 \0 [0 ?
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
# _* f2 u( f+ Q z n3 v$ y- K" C
想确定一下
9 M8 b9 |) o9 e5 h/ C& L谢谢!# h$ m( U% [8 P& ?. ~: k
|
|