|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序% `# H+ a6 y" F' k/ W0 V7 I
其中有一段如下% k' ~4 L6 e/ y% x
ask turtles with [ infected? = true ] # K+ W( j' n: F8 D u- l. D, U
我原本以为这句会回传『所有』infected? = true 的 turtle
( [5 i* B+ ?! ^7 j: H7 @. Q但看结果似乎不是这样。/ A; i/ ]3 w0 q1 `4 A2 U! d& Y
) `4 x; f6 H% E5 [假设所有符合条件的有 5 笔
- Z- [1 |# m) o3 v5 {1 a有时候回传 1 笔,有时回传 3 笔,是不固定的3 B! t5 Q) G& ?- D
回头查语法定义
B0 {7 n3 J( \7 P: ?$ m0 b+ Gwith ' Y' C' W, ^) I
agentset with [reporter]
3 a# C. |" i2 ` S8 P. s4 bTakes 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.
: H' L8 ?& Q3 c它只说回传 agents satisfying the given condition1 W5 d3 ~ y6 E
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
& r. A/ ~/ e2 S% y. K/ }4 z* P4 d8 P @ ~, ?3 g
想确定一下
& t$ ~8 I0 i2 o& ~7 ?1 ~# Y谢谢!& A9 m0 D6 g3 Z1 g V, A
|
|