|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序6 y8 |4 u: j9 f2 u; G8 H" i
其中有一段如下# o2 D% m- \& W2 I" X
ask turtles with [ infected? = true ]
, V! o* y$ r; u我原本以为这句会回传『所有』infected? = true 的 turtle
4 I; W6 e, y0 d3 h但看结果似乎不是这样。
. ~, u* t6 V5 J2 }- ]; V% C8 a! B+ C% i5 y1 ~! p' T
假设所有符合条件的有 5 笔
0 c, Z& [3 Z) b5 G( b% V6 s有时候回传 1 笔,有时回传 3 笔,是不固定的. A+ H1 _8 w Y* \2 i/ @
回头查语法定义
% s& P+ O' A+ g0 s, W8 Rwith " k( m W+ K) o7 Q# m0 Q, y% W
agentset with [reporter], O- w/ }" a! K/ x7 _) j
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. ]8 m) J0 J1 T5 y0 m5 k k
它只说回传 agents satisfying the given condition- R- @0 t$ p* A( n+ d- D
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
, k- U9 f5 f* ^# A; N! S9 w j; @6 O- J/ U' Y- E& k! S
想确定一下
) {+ r s/ j1 j8 _7 o/ A4 E谢谢!
$ C6 V4 O% T( g/ p h% D+ w |
|