|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
9 b' r, C2 T J3 q3 G$ c其中有一段如下$ i: Q1 w" Q+ G4 `
ask turtles with [ infected? = true ] * o$ X+ @. \6 C+ u X1 ?. P
我原本以为这句会回传『所有』infected? = true 的 turtle
: H$ K) l6 w5 j, C$ G( t* W c但看结果似乎不是这样。
9 T" z+ W" O; Q3 \) j( i+ E# M3 \; P1 S
& I* R! c: C$ {" B假设所有符合条件的有 5 笔
' N6 F- [( T' c有时候回传 1 笔,有时回传 3 笔,是不固定的
% k! E$ } \2 D e; z5 |回头查语法定义
: Y r+ E1 C, k5 `) x+ J0 e; Hwith
! h( [% g( R, I0 yagentset with [reporter]) U2 o" T: n" Z7 \) ~
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.+ \( S) z" u# O4 S6 Y; a g
它只说回传 agents satisfying the given condition
4 d# t. c8 \, M2 k+ f, v是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 1 N- I+ B+ u! E5 @4 K
& J7 |0 V, N# M2 L% ^( v想确定一下
# T8 D2 @5 E" G9 P7 |0 w谢谢!
' a' [! ~. N0 \8 d8 B# T4 f |
|