|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
" I* R# G2 k6 k其中有一段如下. k4 X: N) X8 r
ask turtles with [ infected? = true ]
7 ~7 ?" j- e% K$ w3 n我原本以为这句会回传『所有』infected? = true 的 turtle
4 s" T" ]1 }/ Z但看结果似乎不是这样。
- p; H& P1 @# e0 o. A: _* L. z" v/ s7 M0 u! x. D
假设所有符合条件的有 5 笔- ^, _( A, w8 P4 u
有时候回传 1 笔,有时回传 3 笔,是不固定的2 _# L5 y! g4 `
回头查语法定义
2 Q! \9 m1 c2 B" |7 J2 owith . G4 I& @9 H. F- I5 |6 W" P& D
agentset with [reporter]
, `) c; @$ u) L, `: a# 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.
# r) B+ W; |+ m2 o: s; C它只说回传 agents satisfying the given condition" S9 U0 |8 Q& i. b% w
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? : u9 @, X7 [% ]
5 y' c q, N0 A- d C8 u想确定一下) x1 S6 S) l8 K0 E1 I
谢谢!
: v; ]4 Z/ |3 ` N6 f1 S |
|