|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
0 B9 x$ } z7 o( D/ Q3 R其中有一段如下' f0 C6 t& [& K% O' Z* D% R, V
ask turtles with [ infected? = true ]
x" \7 U6 F& H }7 p( C: G我原本以为这句会回传『所有』infected? = true 的 turtle, J0 O% e4 ~+ K" d
但看结果似乎不是这样。
. G! Q6 R; m4 s: b
& `! j: E0 ]/ i3 W9 B: `" y假设所有符合条件的有 5 笔$ T Z$ U8 a8 K% S# x; f( R
有时候回传 1 笔,有时回传 3 笔,是不固定的2 g* q) n: U4 \
回头查语法定义) C' Y5 h5 e" K
with
/ o) X% N4 U ~& O( Qagentset with [reporter]
V- ?$ s. q9 F. x; B v$ 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.. F5 L) k- B& |9 b# C
它只说回传 agents satisfying the given condition
" C, H' v# O F5 O是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
# H( T( S/ |4 p2 d3 c: }* B4 n& Y% X7 p9 ~: p3 _! L. H
想确定一下
+ H1 r/ R a+ J. L. y% V谢谢!
/ A: F5 \! t$ \# o. b( z |
|