|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序* x" L* v# Z+ V8 ~: L
其中有一段如下2 k% X0 C9 O) l' t4 r9 L; L: R9 D+ w
ask turtles with [ infected? = true ]
; m7 C" L: P- s3 R y, q8 X我原本以为这句会回传『所有』infected? = true 的 turtle! V A1 U1 y5 d2 n: p
但看结果似乎不是这样。
; L7 U2 r8 [3 U- _! n2 `7 b7 X2 {- N% O! K6 j3 _, p( J
假设所有符合条件的有 5 笔( P9 [' M# `6 X) ?1 M9 {* U
有时候回传 1 笔,有时回传 3 笔,是不固定的
! P6 ~& `3 z8 b6 \; t& ^) V回头查语法定义, V9 ^+ |( r' E5 R; n0 J
with
4 Y d+ u7 O$ P; h9 k- A! xagentset with [reporter]7 O, r6 ]9 x8 D* o
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.3 a5 ?4 m. v& {( k$ W0 k# I
它只说回传 agents satisfying the given condition$ E7 [1 G: k% ?# h- R- M- s
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 7 K$ s) x& v" G0 H4 R
; w6 F0 v0 F2 r$ K3 K4 u$ T
想确定一下& [2 S: x+ q" s8 }( @
谢谢!$ ?5 s8 `; R8 c) R# O. J' s
|
|