|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
. e- y: M' y" R: @4 k; \其中有一段如下7 k7 e, B2 z, [. q9 ]( U: |
ask turtles with [ infected? = true ]
x' A5 J8 H+ s C" J- g7 n+ l我原本以为这句会回传『所有』infected? = true 的 turtle8 | \; r! n& u# `5 H
但看结果似乎不是这样。
( l( J$ m2 n$ c# k6 B1 x3 ~- h" H. u, w7 X5 y7 T4 r
假设所有符合条件的有 5 笔; o u+ l" _# l0 ~5 r
有时候回传 1 笔,有时回传 3 笔,是不固定的
, o! A8 T4 R( N. b1 H L/ a0 Q9 J回头查语法定义" n/ c$ w( e" f$ a
with 1 T- S1 b0 Z; q# P+ g
agentset with [reporter]) n1 T8 q7 |1 G! T4 C) {6 y% o% 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.
9 [4 U2 }4 O- @% y) g- Q9 I它只说回传 agents satisfying the given condition) X ?! |8 Z: S5 a) `3 x
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
& `4 k7 y% p+ \1 Z$ W; @, Q8 z: x' _! O5 |0 D4 n
想确定一下# M0 t0 N" [/ ^) Q4 G
谢谢!+ k$ i+ O% r. ^7 K& Y l2 ^
|
|