|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序+ Z9 Z; T: d2 t2 N
其中有一段如下* I7 G0 [6 G* d) Q
ask turtles with [ infected? = true ] ! o$ i6 F. Z, t: X
我原本以为这句会回传『所有』infected? = true 的 turtle$ S4 i8 f( a! y, g
但看结果似乎不是这样。$ Y0 p7 O# t: R- E; i5 n5 n
8 X5 s5 G% P8 ~& z, D+ e假设所有符合条件的有 5 笔
" D+ I+ _& Y% H. C2 p有时候回传 1 笔,有时回传 3 笔,是不固定的
J( N. R! c% r! G7 @) Q回头查语法定义- |- j% v! E- b& r" d
with ) H- S; x- O8 I% j& o, W: c' K
agentset with [reporter] G- w+ I$ i; N) y* w/ b
Takes 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.
5 T1 T! X4 e1 y8 `$ f: F它只说回传 agents satisfying the given condition
& m' F! T/ Z* j3 w是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? + B& E* L( ]. p/ h9 ]: h& Q" K2 p
1 h; r+ f, H; \4 }8 p想确定一下
V4 ~, H# _ P* e& c谢谢!
1 V' c, C8 }0 w& U+ I- | |
|