|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
8 V. D& E# _, l) B. |其中有一段如下* b# z7 Y: L1 P) [* L* y+ l, ?8 u
ask turtles with [ infected? = true ]
2 I' E/ K" y" d% }/ R我原本以为这句会回传『所有』infected? = true 的 turtle/ o* f# j) l0 s: D7 D
但看结果似乎不是这样。
' O- M2 b" M1 z/ F4 c) I1 i7 f5 h
, m& c% g7 O! ]( U. O+ Z* ]% h假设所有符合条件的有 5 笔
5 N `' E) a% G; j& g8 f有时候回传 1 笔,有时回传 3 笔,是不固定的
- V/ A" a g9 c! c8 k) R6 I回头查语法定义
3 O2 D6 O4 X, i& v' [5 ^+ m0 |with
+ c1 w: B. D8 i" b6 K+ tagentset with [reporter]& E8 B$ }+ g' @+ I" {
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.+ R. E% z0 ?' S
它只说回传 agents satisfying the given condition
; }( [$ q+ _, X7 g, o3 l$ |是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 8 b" X/ i; N8 u: N! W+ Y
, r8 E g' v2 _0 e* Z$ {: f/ w想确定一下
H2 I3 q/ A( f; r* j3 L谢谢!- c; n8 T, L4 H8 Z! z1 `
|
|