|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
( ?/ A, |" ~3 K# w其中有一段如下* K4 u) F4 C7 d4 Q) T$ s* Z
ask turtles with [ infected? = true ] 4 F' |, w& {+ a/ G3 V5 b y) x: x9 p4 r
我原本以为这句会回传『所有』infected? = true 的 turtle
0 u: K. x. Q# W, O& x; l! D但看结果似乎不是这样。 G, q# t' T7 h4 Y+ J" D
$ g5 u- k3 |- n C假设所有符合条件的有 5 笔
, `) c- R# X6 c1 E4 O- L有时候回传 1 笔,有时回传 3 笔,是不固定的
7 P2 Q$ K" G$ v& Z5 v& L& v回头查语法定义
3 U0 T, |/ p6 v: Z( l7 N+ `) Dwith 8 Z% p2 U/ Y4 w% f I9 b0 f7 l9 J- ?
agentset with [reporter]4 e% c, }) \! g0 y4 w4 L# B
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.
; n7 T+ A! H( o) V4 q2 q它只说回传 agents satisfying the given condition* K4 x% I! s9 ^ {
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
, n- m5 i6 q' P6 g7 A! I5 x4 f0 l* h* V+ T* V
想确定一下. I, W. F. a Q5 m
谢谢!( |- V" R5 f3 s: f; X% C2 t" [
|
|