|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
- k/ a' C8 F( \+ m4 t* |/ N其中有一段如下" L, x: \. I* C; k; w Y) X( O9 T% s
ask turtles with [ infected? = true ]
! |' g8 R7 f( N0 ^! \4 C7 q$ D我原本以为这句会回传『所有』infected? = true 的 turtle
# v0 B# K B! }" I- q但看结果似乎不是这样。
( X( }( i1 f4 C) i4 ?) l. G) m% S: i$ Z! D
假设所有符合条件的有 5 笔
v2 U& \, _+ {4 u2 w" R有时候回传 1 笔,有时回传 3 笔,是不固定的
5 r: ^" }$ [* {) P回头查语法定义! k* \1 a3 {) t0 g" Y: J
with m' S8 {+ V6 Y; J4 X) w5 |
agentset with [reporter]
! j# X2 x6 W) G6 E }+ d, WTakes 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.
y! ^' K+ {* O- V6 _/ {它只说回传 agents satisfying the given condition
& F) p7 w) I! m4 y) m7 o' F是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 6 }) G+ ?, X( \: n
4 g' o& o& {) Q, h; l想确定一下
" c @: Y4 ?0 n. |% l: x谢谢!
( o; b, a+ u+ B" @/ d1 C |
|