|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
4 J! d% _6 j- V, I& ?6 i其中有一段如下. d9 C9 N; j9 T4 ^& w! l
ask turtles with [ infected? = true ]
' K4 z1 E) z6 a# E/ n我原本以为这句会回传『所有』infected? = true 的 turtle- k( ^% W$ c9 r# v; [8 t6 S$ f# L4 g
但看结果似乎不是这样。
; |$ ?* l% o/ b6 E
7 f8 g1 `5 m9 H1 Y! }& r b假设所有符合条件的有 5 笔
. y& ?# r3 t* s5 b* q2 P5 Q有时候回传 1 笔,有时回传 3 笔,是不固定的
4 Q- Q, j9 D, |8 A回头查语法定义
( e) |- L' m! }" e. u! v# Y4 e% Nwith " h/ R4 o5 q- T3 J9 \
agentset with [reporter]
; Q% a/ _" b; m8 C* mTakes 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.1 P5 y6 b1 _& Z- Q8 m- f! w
它只说回传 agents satisfying the given condition8 D# z, a4 P. P
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
* m0 K( h& f' b3 L
! j! G0 v9 Z) y- N% |8 Z想确定一下& p4 J/ x" m" p
谢谢!
/ h( |1 w( V* O* G9 ` |
|