|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序& ^8 T) s! m, u3 ?5 _! Q
其中有一段如下% s6 C# h& ^( C
ask turtles with [ infected? = true ] a) q3 U$ H$ j: E/ ?
我原本以为这句会回传『所有』infected? = true 的 turtle3 {/ v7 |& ]8 E: K1 b2 R
但看结果似乎不是这样。
9 P4 I. m9 u! q$ a1 h
$ F! \9 g0 {2 y- b. H假设所有符合条件的有 5 笔) ?: s9 t+ `( q
有时候回传 1 笔,有时回传 3 笔,是不固定的" k/ _0 T1 p8 ^
回头查语法定义
6 d; e9 P; D. {: Y; Dwith 2 C+ i9 c) k1 s7 \+ k9 m
agentset with [reporter]; N) e1 q9 s8 n$ 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./ I3 E) N. [; U& A$ X3 {& Z! D" z4 u
它只说回传 agents satisfying the given condition
- J- A# A: m) G; x9 Z/ ~1 O是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
9 A0 `. e7 i6 c5 R; a$ f; o/ X5 g/ \! E R6 N# t
想确定一下
, c+ k: a7 f% f2 {" F6 ^谢谢!
7 M/ f r: i# T2 O. `$ h8 Q k |
|