|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序, u Y1 V6 o9 K6 B9 ]5 J1 T
其中有一段如下1 \) e0 j1 Q, c3 {- z
ask turtles with [ infected? = true ] 4 i9 ^# r- f: k( l# q6 i$ N: k2 K# B
我原本以为这句会回传『所有』infected? = true 的 turtle
) D* f0 g; d# z4 S2 V" A! @* v; N但看结果似乎不是这样。
# l5 i: B* u, W, P3 w/ @9 |# E
: g% e/ Q% p P$ B `7 Q+ Q& ?% r假设所有符合条件的有 5 笔# D1 e2 ^7 d; h
有时候回传 1 笔,有时回传 3 笔,是不固定的" m7 Z+ T% \3 d( }3 X2 p6 n
回头查语法定义7 A7 J" o1 V; F
with
9 w) Z( I2 M# Z( j/ {" p& ^: dagentset with [reporter]- S, f8 p9 O, M: |5 R: {) y
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.
8 G1 T# F4 G. C: L它只说回传 agents satisfying the given condition3 v e' g+ _, m; U9 R
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? ( i2 y6 `+ K0 Y2 @
9 _2 j0 I* O! G* ?) A想确定一下7 ^/ c0 e" Y+ M
谢谢!& p% j4 u# X- j: o5 R. V- Y
|
|