|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序- i9 \& C/ b, U, K
其中有一段如下# z" t) c! E9 K. H2 V; H) \
ask turtles with [ infected? = true ] ( w6 O/ |7 u& J! z( O
我原本以为这句会回传『所有』infected? = true 的 turtle7 R+ ^% r* X! [
但看结果似乎不是这样。
: H. _% t$ @! R& K0 ^" T
- ]! ^( E9 \1 _& G$ u6 o假设所有符合条件的有 5 笔
: S9 @5 B f' e9 E2 W' I有时候回传 1 笔,有时回传 3 笔,是不固定的8 {6 f% \0 n k1 G$ V# M
回头查语法定义0 I* P8 d9 {7 P. l6 N6 l) k
with
2 ~( U! H; R" g5 c# g8 h% tagentset with [reporter]
% `& J! ^8 M) WTakes 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.2 _3 i* |6 X' }, B5 B- |2 e- C) i
它只说回传 agents satisfying the given condition
" g6 E3 O9 }* B3 V+ ^是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? " ]1 l( S' y3 k, ]8 d4 D
: t! D, e8 M+ G' s* o7 A
想确定一下
. H) @! c: j' n: Z; y2 b谢谢!2 O) B+ \! U; m9 y; N# I
|
|