|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
. m' _$ J" `! q+ X其中有一段如下4 e* o, n/ z% Y9 @ H
ask turtles with [ infected? = true ]
4 X! _7 K: s3 r9 |9 d我原本以为这句会回传『所有』infected? = true 的 turtle
3 j/ E6 e4 t, d3 x* a T但看结果似乎不是这样。
% }/ B/ }) B) k6 S) [" B0 z5 a. r4 O; s. V, y
假设所有符合条件的有 5 笔5 k x- b+ K! ~4 y( j& k, H
有时候回传 1 笔,有时回传 3 笔,是不固定的
% x( m$ D" r+ \2 y9 p回头查语法定义; l0 e) p5 J( |1 |; d7 l3 x% q
with
4 _! I8 v( ~/ j0 x' @1 y$ Wagentset with [reporter]
8 d( v/ j) _) N0 F" |5 S4 eTakes 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./ _; z; A- W5 G0 O5 s Y
它只说回传 agents satisfying the given condition$ @& O; B/ ~! O# t: M
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? * J9 W) z# x+ p# z5 t% l
7 h5 @+ G3 p- M8 y" S- \想确定一下4 W# G5 G* J: ^3 |# r2 ?# R& Q) G
谢谢!/ b4 u$ ]+ c" H( u$ x) v# B4 g' Q
|
|