|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
6 w" c1 m7 U) P6 U5 d! @- ^$ d) ?8 e% I其中有一段如下3 A0 k" @5 n5 C0 R4 z0 A
ask turtles with [ infected? = true ] 8 C7 Q7 A$ u2 t" r2 o6 H
我原本以为这句会回传『所有』infected? = true 的 turtle# s2 V( t9 g5 x) ~3 n' k, z: g
但看结果似乎不是这样。
& B. w% Z. a8 A
7 y: @- o: v$ j$ q/ ? N假设所有符合条件的有 5 笔/ {8 L% @2 `- S0 k( C
有时候回传 1 笔,有时回传 3 笔,是不固定的
4 e2 Q I* K' y$ h4 q回头查语法定义' @4 x: R: c* x4 L' A9 v5 M
with / \8 r9 ^& F0 p6 z* Z' R) S' Y
agentset with [reporter]8 Q1 w( [0 X( 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.
+ A; x+ ~. \9 l* a. Y+ f它只说回传 agents satisfying the given condition2 g, ^: j( H# y$ P9 o( v. { Z
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? # V1 a& k$ C7 T
, p5 z1 [3 D' A7 R$ F- l9 [想确定一下
, U/ D' H, `0 p& s+ W3 z+ k谢谢!
. f9 o4 ?2 e7 p |
|