|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序; b/ z* X( B- n7 x! X7 n+ l
其中有一段如下0 N/ V1 ~- _: z$ I" S" R
ask turtles with [ infected? = true ]
. V5 W$ X- Y- L我原本以为这句会回传『所有』infected? = true 的 turtle
2 m! f( ?9 }( r' d* u但看结果似乎不是这样。
$ r6 ? U. Y" q' m! @8 n% E" B5 D( N7 k" c1 o ~! Q+ D4 [2 c8 t0 q
假设所有符合条件的有 5 笔, s o% W- e: Y# _' x3 p
有时候回传 1 笔,有时回传 3 笔,是不固定的
2 \9 `7 t5 w- U( C: D. ]* M回头查语法定义
- Q' @) X" B# o7 ~. Q# Z% s7 q# Hwith ) ~3 D! U' `$ v$ _9 l" ]
agentset with [reporter]
! O1 h. A" d8 i. v' |; D6 X% i0 yTakes 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.
) R* h( E( @% {# t8 Q$ K它只说回传 agents satisfying the given condition
& \' E. Z% g3 c( q+ o0 g3 R3 p是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? . z' t W2 k f/ Y& A( H
# o( p# G1 V6 R) P
想确定一下' H( Y/ u3 y3 ^; q
谢谢!
2 O/ C( i0 P6 F3 Y3 |5 b( C8 i6 d |
|