|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序2 s; M- R9 U2 S' U# I3 [
其中有一段如下7 z8 V0 _& }. K3 O9 i6 H
ask turtles with [ infected? = true ] 8 v- n I. o0 U" z3 o4 w* y6 u
我原本以为这句会回传『所有』infected? = true 的 turtle
5 K% P% V5 b5 b但看结果似乎不是这样。
! @( q2 Z8 l4 t9 v/ D) J! B$ _: y1 d) V! W" i2 ~ Z
假设所有符合条件的有 5 笔9 ?" l/ Z1 ]& u1 t& l* b
有时候回传 1 笔,有时回传 3 笔,是不固定的# ^ C- A* e' ]1 i' f
回头查语法定义" ?/ }8 G& f- T# \( [% T
with
4 C% d( \# c( J# x L. |agentset with [reporter]
* N Q$ c) O$ T. Z% ?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.! z7 s f/ \7 b3 i
它只说回传 agents satisfying the given condition- n9 X* j! X9 W/ G! H8 i, L5 g
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? : `/ o5 i! A! O) C1 V
4 z5 `* Z3 i0 r; F8 a7 C想确定一下1 e5 A5 I2 L' L: m7 R" W1 Y* G$ k7 m
谢谢!
# ]" x+ _, [! B: S ]0 M |
|