|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序 [5 l( C" L( I9 P. H
其中有一段如下5 S" a" ^, x! W. L ~
ask turtles with [ infected? = true ]
0 s% u2 i5 Q& }6 z: Y+ D" c我原本以为这句会回传『所有』infected? = true 的 turtle: v& T5 @( ^3 @4 Y
但看结果似乎不是这样。! T5 a1 [0 z" ^5 y% o
- O5 A7 c6 ^& S2 F* d+ I3 e
假设所有符合条件的有 5 笔
% j; ?8 [9 b4 P8 d7 o8 j有时候回传 1 笔,有时回传 3 笔,是不固定的1 M% i; \5 k% g" X
回头查语法定义- c" P6 a" _* ^& G: S
with ) @6 b+ y9 _. }" v
agentset with [reporter]
' T6 b5 |2 t- x; [, z2 S/ {- j* OTakes 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.4 b" h! O4 x& |+ ]1 }# T
它只说回传 agents satisfying the given condition
H" r1 E! i8 W- N, R! U3 T9 ~7 u是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
4 I" Z. _5 z3 w3 ~1 O- c, V0 {
% p2 }& i L6 _( E& }# C9 F想确定一下
" E6 }. @/ p! k5 {, l谢谢!! V. Z# M( @' G9 G: t$ }5 m- `
|
|