|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
+ A& _- _$ f. W其中有一段如下9 m: `& B, V: D7 B; x
ask turtles with [ infected? = true ] / I4 v3 r. p3 D' j; k3 s
我原本以为这句会回传『所有』infected? = true 的 turtle+ ]& s) T+ ^! |& l0 c% Y( ~- `: d* y
但看结果似乎不是这样。
1 D6 R3 V; t/ {% _: H9 h& b
* s& S. [: s* P; I+ J p; S假设所有符合条件的有 5 笔- q$ |" n4 o8 e, l x/ A7 Y
有时候回传 1 笔,有时回传 3 笔,是不固定的2 A( t' M! F( ~/ \
回头查语法定义
+ y K, |2 P. @4 W& j/ W% {6 mwith 7 a o8 S. @; Q4 p) I
agentset with [reporter]/ J- R+ J# D" v
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.8 J( F4 I2 ` n
它只说回传 agents satisfying the given condition, d1 d; _6 ?# g1 r E" I
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 9 }( B& P& B0 _* ?6 J0 o- [
+ Q1 V6 C- J8 W4 B) f$ y% g想确定一下 n; L; W; A) l$ U
谢谢!
9 h$ U6 W6 e/ i: u( C0 t |
|