|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序6 _6 r& K0 \+ J! |8 A: S5 I
其中有一段如下: j' Y4 m, E" F0 V/ b, N
ask turtles with [ infected? = true ]
' r9 r d8 d" v( ~- U我原本以为这句会回传『所有』infected? = true 的 turtle
$ b3 J# u; ]- a( J0 `: p. I- V! n但看结果似乎不是这样。
T2 H# v6 |9 B; ^) s3 X3 A L" X; j
假设所有符合条件的有 5 笔' F/ q# k5 ?: x( s
有时候回传 1 笔,有时回传 3 笔,是不固定的3 K- r# h* P$ u6 {' x2 t0 v: n
回头查语法定义
T. J' _* W. w! cwith 4 S4 S7 n9 L$ B1 `
agentset with [reporter]
( p s6 d0 s' E" L# P( L1 w: C3 uTakes 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.
7 y+ c; l* B1 t. f它只说回传 agents satisfying the given condition
, @3 n& K3 k$ V' W是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 2 |+ p5 x( K( B/ l; P8 {) W
% G/ h5 w8 `9 Z2 u
想确定一下3 v" w; \! X W% A: F, q6 P M
谢谢!
$ D5 Z/ e! _8 m1 G |
|