|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序: V* A, z2 k8 {& Y2 M9 Z2 w( z' c
其中有一段如下
) u% A; _# U% I* x1 D4 @ask turtles with [ infected? = true ]
. W& W: D% a1 F S c我原本以为这句会回传『所有』infected? = true 的 turtle
4 @; k8 A: h% l: U9 \但看结果似乎不是这样。! K& K) W) [$ t
6 X: d" T/ p" f假设所有符合条件的有 5 笔0 l; y. U g( M, n6 \4 a
有时候回传 1 笔,有时回传 3 笔,是不固定的, O3 U8 w# x; U/ O$ f( Q" N8 y
回头查语法定义
/ Z/ O2 F: b& o* Cwith $ N I5 M* }: {& Q1 q0 F$ X# ^$ o
agentset with [reporter]
& W# s' m- F, u' LTakes 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 M/ H6 R' }4 ^, ]+ I, x它只说回传 agents satisfying the given condition
% V: `' x& z6 e是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? ( J2 k" l! k* r- o! W, l4 n, j
/ H v! S" U+ M想确定一下) h1 B# T1 m- X S2 ]
谢谢!
3 r1 W' q3 Y1 n0 a1 K4 _ |
|