|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
" N+ f0 h5 B* s/ E; V, J1 Z其中有一段如下( u; {4 k3 J9 J1 D- x" c
ask turtles with [ infected? = true ] " Y6 @3 P1 M l- h
我原本以为这句会回传『所有』infected? = true 的 turtle
( _4 h- f; ^* v: T/ O7 q S" z但看结果似乎不是这样。
: e1 P6 _/ f8 P& Y7 q% Z* J
* r) a2 R" H* Z9 @, J假设所有符合条件的有 5 笔8 S( h$ Z3 U+ j5 [$ b
有时候回传 1 笔,有时回传 3 笔,是不固定的5 I2 h7 |# h- \3 B: [" K
回头查语法定义
) @# |4 J0 @4 A( H" u5 x, Fwith
1 Y2 J3 D$ d8 ~" `% D+ l' o% o* Hagentset with [reporter]
3 |9 w! K# p2 z8 I; eTakes 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.
9 o/ W0 v- c9 z V0 Q8 U1 q它只说回传 agents satisfying the given condition" K7 s" l) x& S: m! A: R; Z
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
) e- X9 i* t% }" P+ ~# o5 O1 h
) a: k! h. E4 W& f& y想确定一下0 `6 q2 K) `& ]/ k. ~
谢谢!
% F R# c- @% d, |+ @+ b& N7 R/ s |
|