|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
9 X' P: X& p$ P6 v8 i' z# u其中有一段如下7 W2 g7 r( }5 D5 S/ z7 ?- c
ask turtles with [ infected? = true ] $ m* P4 q4 @ c
我原本以为这句会回传『所有』infected? = true 的 turtle
" _4 q7 ]* K! A* Z" {但看结果似乎不是这样。
; p0 p$ {! p* C1 E3 B/ t" |2 L; z
) K$ |) a9 N. s: ~假设所有符合条件的有 5 笔
- o" b% {$ e6 R% O1 H/ i3 \有时候回传 1 笔,有时回传 3 笔,是不固定的
( H e3 o6 W+ K( r) f5 G回头查语法定义* X7 z+ g2 N2 W! _0 S+ N
with 0 G% [5 x! o. t+ X0 b6 i1 `, t% E
agentset with [reporter]
! g* e; t6 P' P! K3 ~# r- B( f. ITakes 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.
& ?( _5 f2 Q& D* l4 K它只说回传 agents satisfying the given condition
( c8 J. d2 {0 {; G' Y是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? " j. q! e: h: G# s: L) y
& t1 J" f% Z6 V9 g想确定一下
) S- S% k! L. ]+ H3 e6 a) g谢谢!; @8 g9 _0 `5 F' K3 |# J$ d/ F* E! L
|
|