|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
2 F& f3 g1 T. M. \. L( X' e) a其中有一段如下9 n3 \6 ]& ^' m* i" Q" S: s
ask turtles with [ infected? = true ]
4 R$ |* o. U( ^2 F我原本以为这句会回传『所有』infected? = true 的 turtle
6 o; t" K& d0 `* B% c# u2 e但看结果似乎不是这样。
% F, \+ p; c3 N, y8 t' C: E# f" b. w h0 Y! L+ L/ F, C! ]
假设所有符合条件的有 5 笔, k" j- K2 E) W# f; |: o
有时候回传 1 笔,有时回传 3 笔,是不固定的
: {. R) N5 h% A1 [5 z回头查语法定义6 d+ L) Y8 |, `9 a0 @# \
with 0 x f2 {2 w8 r9 j$ O7 ]
agentset with [reporter]
" U. t5 I0 Y9 \4 j1 M7 a: j4 M9 H: QTakes 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 n ~4 b. N% [
它只说回传 agents satisfying the given condition' t% `/ o) _7 H: T9 g2 T" L5 X7 W
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? : z# A4 n# w1 m6 t* L1 u0 R8 g
$ K: |* R' U2 n# }$ C6 v$ f2 g想确定一下' d1 ` ]3 p" K
谢谢! ~2 R3 Z6 J) S4 g- Q
|
|