|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
, x' R; f/ O3 `$ F" i/ ^其中有一段如下7 t7 [# \! K+ y0 m D7 f
ask turtles with [ infected? = true ]
6 |4 Q5 p, @& y; F, G* o) e' y我原本以为这句会回传『所有』infected? = true 的 turtle+ w# n1 }7 y+ D
但看结果似乎不是这样。
$ C7 W2 x- f1 n5 t! a' P d+ G! F. x, p% K& w
假设所有符合条件的有 5 笔
5 D4 k/ H/ s9 A- ?4 ~1 ]% M; W; m8 E有时候回传 1 笔,有时回传 3 笔,是不固定的
7 u9 a2 E- G" ^" q3 U" V# u9 }+ c回头查语法定义" L" u4 W% S4 n# c" s
with
* K0 B+ ~6 w- \9 p9 Ragentset with [reporter]
8 n: ^( H4 @, r" ?$ T" FTakes 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.
0 c( Z- ^+ h2 q, e% V0 T* L它只说回传 agents satisfying the given condition* q3 r% W$ o" j2 A; Y
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
; ~6 C: l. x- m: _# g' T( `, J8 E) `. I* d
想确定一下. q- ]; n9 [8 Z3 ?" Y! `
谢谢!8 `; N5 U3 e r$ B8 n6 Z
|
|