|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
2 i5 w* M0 o" c7 K. E5 k其中有一段如下# ]# g+ K$ N- g$ V
ask turtles with [ infected? = true ] ; Y1 [( W9 ~2 C; e' \/ T
我原本以为这句会回传『所有』infected? = true 的 turtle
! N' U X6 p# ~$ I; @! }但看结果似乎不是这样。- h0 r$ \$ U, q j/ c- v" @
- N Z8 f! S3 i5 {8 E( v假设所有符合条件的有 5 笔5 `2 H5 P; t. T; P; H" R
有时候回传 1 笔,有时回传 3 笔,是不固定的8 N, h* I$ z8 t8 v, y+ c
回头查语法定义
4 U, i0 r1 w# r% `7 Q3 }3 Vwith . G2 @/ |: C: o* R; _) q+ @
agentset with [reporter]5 x- X: b5 ~" A6 K8 O2 e+ b
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.# U% [% }/ ]/ j5 q$ j: H( l
它只说回传 agents satisfying the given condition) B. U4 O& G5 m* `' K% ?8 c! {
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
b# y! V! l# K- [% L, t1 }- T$ \
* I, N {3 Y7 m想确定一下( T0 a& ^, M) Q% O' y! l. T
谢谢!
7 N' F# p) P( P& v' R; ]6 B |
|