|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序& X0 F$ h$ c! o
其中有一段如下- M8 f8 D6 K/ J+ G2 u
ask turtles with [ infected? = true ]
$ X% ^- r" H6 I# `我原本以为这句会回传『所有』infected? = true 的 turtle
1 t" ?; @0 X( {0 @3 C& X" O4 ?, w但看结果似乎不是这样。
( Q7 ~8 n0 e2 z
9 E$ b" ~' v# w- M' h8 N# F假设所有符合条件的有 5 笔
/ n8 d2 @! T; D }+ z6 {有时候回传 1 笔,有时回传 3 笔,是不固定的. e/ h5 x( J- D
回头查语法定义( n2 W, U* s% G2 S; T0 q; g
with 5 p* N$ v2 F; `6 Y# H
agentset with [reporter]
! Q" F% N' {8 y( ^9 E; _0 ZTakes 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.$ k* B. T. b# G* r
它只说回传 agents satisfying the given condition
' {& N4 G/ ]- O# j2 Y- X- ]是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
- i% n% @7 E8 |3 g' ~' U* T, r! \6 @$ G0 V$ s' h
想确定一下# S. W; y1 R* |7 p; [
谢谢!( @0 t+ @6 u) b+ P+ {2 g0 E
|
|