|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序- z* z# }" L# n9 X: Y7 [
其中有一段如下
) ^1 N- ]& t0 a$ B' T$ gask turtles with [ infected? = true ] & Y6 z6 \# N: X: S8 q3 _* h9 L1 M
我原本以为这句会回传『所有』infected? = true 的 turtle
& A& o) {& {8 n/ U; L" t但看结果似乎不是这样。
; p3 q$ r N, y8 u9 B
& r' d8 w# Q( f: f4 s假设所有符合条件的有 5 笔; z5 ?4 T/ z& W( ^* Y
有时候回传 1 笔,有时回传 3 笔,是不固定的
! s/ B; Q& w r7 M+ g回头查语法定义
& c$ g. `( Y4 d2 u4 Swith 2 Y: z8 Q) u% E' G- L K! c
agentset with [reporter]
0 p. z/ a' _3 r: d( f" T' ETakes 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.
! Z# ?( M+ J# b& }8 _/ h2 k它只说回传 agents satisfying the given condition
* r; A) M7 ?# m是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
/ G: Q( F4 c. @6 b( @* S) |
; _4 f3 X+ t$ n$ V0 H& Q5 G想确定一下0 G- ?8 h; p% T( ~/ S
谢谢!
" q# |9 k, y1 H; X) k( f2 a |
|