|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序, U- T: j; ^$ }$ @' G3 Z6 c
其中有一段如下
( b' G5 V; Q" V# u* E" Q3 {3 |ask turtles with [ infected? = true ] 9 K2 ~ a( J/ |. b- H
我原本以为这句会回传『所有』infected? = true 的 turtle
7 O$ I- m/ g4 [' O$ t$ y }但看结果似乎不是这样。
9 m, L; t+ k* h: h: E
' W. {3 |( f* d3 f9 `假设所有符合条件的有 5 笔# }$ v) ^* j2 B- |- Y
有时候回传 1 笔,有时回传 3 笔,是不固定的7 \4 k$ N) H% }: q( @
回头查语法定义4 r7 a- i+ p' d1 F9 a( Z
with ; Q" l0 f$ ~# J! W
agentset with [reporter]
9 i' x5 v) Y) q1 E) s E! N& iTakes 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 b4 [. T& X0 i+ ?
它只说回传 agents satisfying the given condition
# _6 \/ H2 j B# c3 f. c是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? $ {# u5 R0 `/ _$ _
: b+ B: [5 |. \7 K8 D想确定一下
$ G9 T& B+ l: f% t0 O谢谢!$ g* D4 w; C+ ~3 M
|
|