|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
9 X/ Z6 E) `/ N其中有一段如下7 d5 {: {; W, p u+ f
ask turtles with [ infected? = true ] $ Y, l7 A7 d. O2 t9 [% X
我原本以为这句会回传『所有』infected? = true 的 turtle- Q( ~, }& S7 }! S& J
但看结果似乎不是这样。/ A, V% D3 {6 S0 j2 y' ^
) a8 f* R7 ?* K8 C假设所有符合条件的有 5 笔$ @( R3 F& t9 O5 R1 l# q: A' a
有时候回传 1 笔,有时回传 3 笔,是不固定的, U6 \( X, ]$ m) F% ?0 |! J8 d2 L
回头查语法定义
+ f% o2 r# Q4 A! Uwith 1 a# }. k1 J9 a
agentset with [reporter]# _ ^4 _6 B K Y
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.
- \# i. H( }1 I+ O% D& h它只说回传 agents satisfying the given condition5 F5 {, R8 p4 U0 P; V0 J
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? " m/ s9 j, i7 I# H
4 h+ ?- m" ]9 X& O7 E: O
想确定一下 Q t1 r; `- y: @/ w$ v+ }2 ]
谢谢!8 z' c) M+ n, n: A- O$ t
|
|