|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
$ c ?& G/ r6 x* n6 K6 f, J6 T3 G* H其中有一段如下. S. a+ \( u* j, A1 i6 q0 A" h
ask turtles with [ infected? = true ]
! O+ T( v2 i: o; ~+ \- J我原本以为这句会回传『所有』infected? = true 的 turtle
7 I% R9 m* y: c$ m* P但看结果似乎不是这样。3 f/ P4 G3 `9 @+ D0 c5 R+ [
3 F6 p" j4 p; O5 C6 M2 h( K: w
假设所有符合条件的有 5 笔
$ R0 K, Y+ W h$ M% ?, G有时候回传 1 笔,有时回传 3 笔,是不固定的
% K* f @9 L; z& R ` J+ Q回头查语法定义$ b$ Z% F* Q% I- G3 v. ^
with
. R+ W. ^. n8 J# C8 H* Y# c0 Iagentset with [reporter]
# H3 p3 X! H: U' mTakes 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.
0 {! {: G4 q% N5 E它只说回传 agents satisfying the given condition
# A. j8 J0 L0 }' ]/ m# U5 K. O* g是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
: @5 I) T) b1 J3 e$ Z9 X) r& ~0 G5 t! J$ i. a
想确定一下
N0 q6 A* y J, P+ O2 R谢谢!$ g8 b3 z) w! U
|
|