|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
( R$ p' i6 @% G' w2 {% }其中有一段如下1 V/ v" O! d! L' F0 f T
ask turtles with [ infected? = true ]
- z0 U* j. |1 k- y/ f我原本以为这句会回传『所有』infected? = true 的 turtle
+ M) @; c8 m6 r1 [7 b& \, m) Y但看结果似乎不是这样。
: }. ^ E. ?& r j! u5 k( w
1 j: Q1 v7 C7 ]& z! J2 L3 m假设所有符合条件的有 5 笔7 }2 O J l+ s. E$ i
有时候回传 1 笔,有时回传 3 笔,是不固定的: z) s% ?% p3 T) G8 U6 D
回头查语法定义! K* ~7 i4 X) \; Z
with
( j0 ^1 j: n9 w4 W. Y- A7 Magentset with [reporter]# A5 @! D# X9 i5 G# t
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.
' G1 l% q; p# J" S3 T2 ~它只说回传 agents satisfying the given condition
# m1 X! D6 p* ~( @8 L+ `7 t是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
6 B# C! n& N- F+ g( H
( e! t' p4 {7 h2 N$ h想确定一下
. ?7 M% e6 f* _; W谢谢!
# c! F# }, i9 i |
|