|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序% C* m3 R8 i6 ~; U
其中有一段如下1 h5 {- |1 c! L8 g" D0 ]
ask turtles with [ infected? = true ]
# S4 d8 ]7 U- R, H% {$ \我原本以为这句会回传『所有』infected? = true 的 turtle/ C5 ]* D" C {8 u' y7 w8 L- P
但看结果似乎不是这样。
8 {2 |7 X @: e4 e1 q5 |
7 \$ s$ x$ B! a( ~4 J假设所有符合条件的有 5 笔, K5 z y5 i( N% h( K1 |
有时候回传 1 笔,有时回传 3 笔,是不固定的, b1 x: O6 w+ j0 T
回头查语法定义
h' s& O) ?4 |with 2 Y: l' G8 |- Q: r
agentset with [reporter]
5 ^* w; B" w0 E2 ~& L8 O% }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.
3 @) Y4 o; Z; k9 p它只说回传 agents satisfying the given condition& ?0 D9 W9 M3 J
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 5 D3 i6 }% g, Y
& J' f; F! c& s- s( z
想确定一下8 d3 I4 H' {' O1 @4 h3 J6 o5 s
谢谢!
* H6 `! E6 Y& q: q; j3 h2 C |
|