|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
( k( H1 i+ i0 ?' J& P其中有一段如下% N! j& m3 U& {' U* \% @
ask turtles with [ infected? = true ]
; O4 b5 n0 w& `( Y0 i4 R, z c3 v' n: A我原本以为这句会回传『所有』infected? = true 的 turtle6 R5 I) f# |0 t; j" H; u5 P a5 \
但看结果似乎不是这样。' \6 ^" l+ D1 ?. P- m) I
3 S: w5 s3 z) f2 [6 c" A9 b& t& v9 j假设所有符合条件的有 5 笔4 O% \4 Q; Y, W, n2 R. h( E# R( [
有时候回传 1 笔,有时回传 3 笔,是不固定的1 W2 S% l1 P9 ~5 b' x* k
回头查语法定义
4 s$ \, O* n8 x* T9 n2 v, swith
1 @6 U: f8 q0 E) eagentset with [reporter]5 A S% g+ G0 ~0 a4 ~& v
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.2 F+ y. v/ O- P) w8 t$ `* W
它只说回传 agents satisfying the given condition
; l3 ?, t5 ?( g' U- t# F) S( w$ F, g是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
. N- ?/ z) Y: A) v1 h$ B! e6 M+ G% y$ _& u- A- w0 u7 n5 ^' R# l
想确定一下& l' J" @/ p- z; T+ W5 a
谢谢!
- \7 s: j7 ~4 {3 ?$ M& q8 @ |
|