|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
& j9 @9 ?+ A4 w) {其中有一段如下! z0 t: B( P/ `9 o& N: E6 q& o
ask turtles with [ infected? = true ] 3 s$ V( P3 w; ~& z
我原本以为这句会回传『所有』infected? = true 的 turtle1 `0 v/ |: D" A0 s7 U
但看结果似乎不是这样。
3 \0 w. f# ?7 ^1 G
( d3 M" Z/ I+ a0 W3 G假设所有符合条件的有 5 笔
1 ~5 c" z [7 r1 i# v0 j有时候回传 1 笔,有时回传 3 笔,是不固定的+ I* H, ]1 J, K) t% f5 N$ j
回头查语法定义- M, h! C t; @) J3 y/ c9 r1 r
with
# T& K8 e; U6 P, ]* sagentset with [reporter]: C/ Z* y7 M" m3 N: Y/ t& B/ I# w
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.
) o- q7 R9 k0 j它只说回传 agents satisfying the given condition
& Q3 i7 f1 Q; P, i7 X! M6 ]是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 7 M# b! e4 Q+ a. i( ^
7 P+ n; i- i6 v6 {) O9 }想确定一下, u% |: @; L* d9 O' R
谢谢!
( D' T5 p" r' f" X1 X5 F3 h- d |
|