|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序: t9 L8 Q) y, K: p; O% z! J1 g! }
其中有一段如下- T9 _: I/ }- e% Y2 f
ask turtles with [ infected? = true ]
/ ?; q9 [4 O& v' j我原本以为这句会回传『所有』infected? = true 的 turtle ~1 b0 m3 C9 T7 [
但看结果似乎不是这样。
8 R- C, C$ E% K; v2 p2 l6 T
3 V- q; l* T. g/ I+ d5 W+ W( U假设所有符合条件的有 5 笔
+ I& u+ \1 e/ j, @) A! h3 ~有时候回传 1 笔,有时回传 3 笔,是不固定的! y, G* I5 T$ g3 ^
回头查语法定义
, E8 y: M2 ^9 }: J3 B0 t- a* ?- Ywith
% W w7 @* t4 a- @agentset with [reporter]
5 S! Q: x; J3 l0 hTakes 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.
- H5 J I k7 y+ S" Z它只说回传 agents satisfying the given condition
" S( _7 t# G& e4 @. r是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 0 g( _- ~! v1 ^7 E8 q
& w2 N. Y. S J! @
想确定一下
/ X' o+ j- r0 v* h; f" Z谢谢!
( Z$ K/ A; K t# C4 i" d4 _ |
|