|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
$ W7 w2 n) U+ M& L" g其中有一段如下- i' c p; f. K6 W8 [% I& @: {
ask turtles with [ infected? = true ] 1 p" \- Z" w/ k, n: v0 Z
我原本以为这句会回传『所有』infected? = true 的 turtle; k7 h$ Q0 c2 f8 r' g( _
但看结果似乎不是这样。
5 B t8 {* t/ Q, O
7 ]2 O# B! R/ G$ e, V0 [假设所有符合条件的有 5 笔
, N3 J! a$ ~, ~有时候回传 1 笔,有时回传 3 笔,是不固定的+ h2 [0 H ?9 b! B( `
回头查语法定义
4 B8 W0 t7 q" ~+ ~with
" K6 ]) F1 w. N; F( G- tagentset with [reporter]
3 P/ U0 y, \/ ?6 I* cTakes 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.
: N) y! y: f3 \0 a f它只说回传 agents satisfying the given condition. k, d' u0 C6 ~1 @+ X" d' P2 h) G
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? * }# E" f8 \0 H: h& a9 w$ {: v
% s& G$ h$ r: L
想确定一下5 ?7 p! o: ? A# c1 K: t5 K4 ]
谢谢!
/ H3 _6 c6 Q) T- D( k4 a |
|