|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
% X; n* c/ H2 K其中有一段如下* m4 u, d3 y) J3 w0 B
ask turtles with [ infected? = true ]
$ C! F7 V5 J. S, f8 O. ~我原本以为这句会回传『所有』infected? = true 的 turtle4 ^% |) E" V# h- d
但看结果似乎不是这样。, _, X; I. p, k( M7 Q
; k6 C w# b& ]1 g- T' F: N假设所有符合条件的有 5 笔* W+ B3 r; f) u% J' w1 j6 i
有时候回传 1 笔,有时回传 3 笔,是不固定的) @1 W; i% ^3 Y- W
回头查语法定义
2 z& K- a* M$ M, \4 a) m5 owith
2 U) |. F1 b0 Aagentset with [reporter]4 X0 f6 F- n4 L/ J! 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 j- E N, r3 C. Y8 j
它只说回传 agents satisfying the given condition8 z" Z: ~9 c5 m" b% R
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? " i m: }* T* C5 n
! X+ Q! Y2 N, j3 z
想确定一下
" Y* H, V7 s/ @: V0 K4 q% U( w谢谢!' a# b2 Y; g; P6 t
|
|