|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序1 e7 Y0 o/ H9 X) F
其中有一段如下; {; C, a2 H8 O* M% {1 O! C8 T) R: c) @8 x
ask turtles with [ infected? = true ] 7 O( x4 n' u; N# f, p, A3 g
我原本以为这句会回传『所有』infected? = true 的 turtle" p9 T" r4 e! V) s' B7 J
但看结果似乎不是这样。
6 P( v9 j! D" [% b3 z( T% H# n& K# T. L7 v- e3 \ h
假设所有符合条件的有 5 笔
8 p2 O, w3 A, g n5 f2 L1 u有时候回传 1 笔,有时回传 3 笔,是不固定的
4 E* J( u5 S9 W' B回头查语法定义( j+ E! N- I& V- d. h0 T
with
, N6 n" w+ M+ ?9 u9 c$ Zagentset with [reporter]
" g" J9 k. a; O' zTakes 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." j( `: Q3 W0 n( T) K% i% [1 k
它只说回传 agents satisfying the given condition3 I2 y0 n& W5 z0 x! U+ _' B
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
: y/ c J% x9 ?% X, u9 v
8 U4 n0 S9 ^+ i9 y0 h* w想确定一下
1 D# W0 S$ N) _# ?/ i谢谢!
$ I8 S/ j2 y I |
|