|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
" w" L7 n" B4 W$ \% x其中有一段如下3 D% @3 \+ m# d8 ]
ask turtles with [ infected? = true ]
, `1 P- I+ W8 G2 }我原本以为这句会回传『所有』infected? = true 的 turtle
0 t: W9 h/ \9 }6 P: H5 C但看结果似乎不是这样。
/ _, V7 E( ], U; U' q5 U/ y+ |) l8 T: m; Y5 T2 z
假设所有符合条件的有 5 笔% ?( t( y* [- {+ E [
有时候回传 1 笔,有时回传 3 笔,是不固定的0 c* x1 I1 h- R/ Z7 W4 T! l
回头查语法定义
* r2 M2 B& L; n) e0 k3 U7 `with
2 W1 M, H' f3 C8 `. w2 i) Vagentset with [reporter]
! k& G+ F R; E, s# ~7 HTakes 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.
8 b8 O& x; \, K$ P. t$ j# d$ I, I它只说回传 agents satisfying the given condition) b! f. \% l8 T2 \6 O# r9 z
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? * P$ r I* Y$ q* [- K' @; t
( V1 t% D9 p. }. g6 w( @
想确定一下8 X$ y0 {& i' G, g! K9 O4 o; a( y
谢谢!
. J K$ j' w# j |
|