|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序% k5 i8 u, P9 S' w
其中有一段如下4 H. {: \. r1 u$ U4 q! r: g( i& h
ask turtles with [ infected? = true ]
# J; W6 |+ S- Y0 F2 f9 N我原本以为这句会回传『所有』infected? = true 的 turtle
' Z0 E: e7 W, A8 b D但看结果似乎不是这样。
g+ I: v* ?( E ^9 w6 u
/ C( H0 h: m5 [3 y假设所有符合条件的有 5 笔/ _3 Q/ g C9 k+ n! s7 R
有时候回传 1 笔,有时回传 3 笔,是不固定的
5 D& `6 I" }% t( n0 E4 u回头查语法定义
! J3 ~5 m4 W+ m5 f* C. O* dwith , m6 y# S% D( l7 w2 r3 {* w
agentset with [reporter]
" _0 F" I3 ]$ N6 v' cTakes 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.
& c0 M: U5 ^* A6 c# W它只说回传 agents satisfying the given condition
' n6 y2 T$ m) \" @) J' y* v是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? , }/ R: Y& v$ y. \1 P
1 W/ o8 V3 p1 i. Z想确定一下
Z2 G4 _" u! T1 H0 w谢谢!
$ m) ~* U6 w1 t5 ] |
|