|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
8 z$ D) r% D& S1 D8 c% s9 I8 S$ ?8 u其中有一段如下1 |3 l6 f' c6 u5 h) B1 {
ask turtles with [ infected? = true ]
8 R5 n' x: v: ^$ ]+ e9 R3 U8 m; K我原本以为这句会回传『所有』infected? = true 的 turtle
6 R1 K4 a9 v) A2 W4 j4 d4 A但看结果似乎不是这样。& |; Z$ V7 `* Z+ ?
1 J& F0 [+ n# {2 A/ x, `假设所有符合条件的有 5 笔
b0 k; a' G# x有时候回传 1 笔,有时回传 3 笔,是不固定的) T$ h8 [ d+ C5 K9 P
回头查语法定义5 I) _6 V& i/ |$ l9 |& L, [5 G
with
* @1 j, L) ~8 S9 H: qagentset with [reporter]4 w3 i" L8 |( \0 e$ b3 z) D& F
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.
1 p' p4 ]8 @/ I. y v# }' K0 M它只说回传 agents satisfying the given condition
9 U6 P5 ]' P9 @3 u% ]是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? ) r: k& l0 E4 Q! p9 F( n# Q
+ ?; R7 Q/ s. M, o N! A* _
想确定一下
2 q k- h2 b F) L7 h0 j谢谢!
0 P! ?/ o! T0 { S2 A |
|