|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序/ ?6 }3 j# V, r# W2 ]1 O; p
其中有一段如下5 a3 f k& P2 I
ask turtles with [ infected? = true ]
' v2 F7 T9 Z/ b; ?我原本以为这句会回传『所有』infected? = true 的 turtle& j9 W0 @* _4 x7 O
但看结果似乎不是这样。
; e( ?! c; b3 A8 I. D
3 L4 C) _* G9 F9 U9 U5 b/ }假设所有符合条件的有 5 笔% i2 k+ h: g8 x3 o! ]
有时候回传 1 笔,有时回传 3 笔,是不固定的
0 Q' x# g: Y4 W2 f回头查语法定义2 e" ]: z) w4 p+ F
with
8 B8 Z& V4 M3 |* \" m Z# Lagentset with [reporter]
0 X& s5 o: p' Q( U iTakes 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.
( A7 V" F4 d" M8 Q( p ]& n它只说回传 agents satisfying the given condition
( ^ \. o$ q2 E: w是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
2 y# q& P4 \+ {5 q t6 Z% H5 d) J4 r) h5 K9 C, R8 Z- l
想确定一下
0 q- n3 V. G% @1 c& A谢谢!
" t H* I$ V6 J( s- ]$ k9 w& E |
|