|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
3 _1 {" S. B; k4 y- f- r6 x其中有一段如下 e9 q4 w F# X6 t' _' n/ Y4 W) H
ask turtles with [ infected? = true ]
0 f: f$ {4 Z: s* f( \我原本以为这句会回传『所有』infected? = true 的 turtle4 P: q, b+ y, }& G* L+ s
但看结果似乎不是这样。
6 z$ C+ E0 `8 @" t- x G
) T4 c6 _1 F2 Q6 X# @假设所有符合条件的有 5 笔
* | Z F* D5 z6 H& N8 @* o有时候回传 1 笔,有时回传 3 笔,是不固定的, h) e5 s* N" c X0 W( k
回头查语法定义1 V7 F# A, ~/ j9 B* k
with / ~2 h ~7 v; F- P, |- d" c& {
agentset with [reporter]
; } C# H$ F) e- a, A; yTakes 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 k/ W# ]( U( @6 S. y. S5 ^它只说回传 agents satisfying the given condition( T! U1 j: S# A- q/ D
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? " ]& J7 F7 U+ J1 j7 G- { Z
3 a4 u6 d2 @4 O. n+ L
想确定一下
$ B3 ~8 q; G9 {! o) P: _谢谢!. d$ J: @; t% A% _
|
|