|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序. B8 a7 ^- O& {: y3 B6 R4 G
其中有一段如下# ~- A9 t/ L) Y! H
ask turtles with [ infected? = true ]
- p, J. q1 \7 p2 S& `4 R* m我原本以为这句会回传『所有』infected? = true 的 turtle
, n6 g+ ~/ L n B; e但看结果似乎不是这样。
0 X" c2 Z) p" a3 n' o# r, M+ Q* j$ l7 n+ d9 _/ c
假设所有符合条件的有 5 笔
% u; @# W- v, ~/ Y" N# n有时候回传 1 笔,有时回传 3 笔,是不固定的
* p: M4 ^/ e% Q3 g回头查语法定义
" _$ k, C( {, r% N8 q m* Xwith 1 g+ E; X8 ]9 [ `
agentset with [reporter]
4 J4 K3 n- F2 [: t5 ATakes 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.
0 d% c1 P+ A7 G$ v/ p: V# {7 S它只说回传 agents satisfying the given condition% O% W' N) X3 K5 G7 ?/ s- H8 U# }; t
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
5 d( K: y6 {# L8 ?+ z
( S- q* ], `, f( d2 X' H想确定一下
( U1 L0 E8 z$ B0 j谢谢!! R7 Q! A: R# X! d8 p
|
|