|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序3 f$ I: G9 t. F% i4 z2 B
其中有一段如下, Z% H: J3 t& }
ask turtles with [ infected? = true ] 5 c; Z5 f3 G6 f% ? k F
我原本以为这句会回传『所有』infected? = true 的 turtle x& C1 y8 y( T; R- L& c
但看结果似乎不是这样。8 D" n& j5 s2 P9 s& m2 z: x
8 l' Z, e Q- n5 l- T
假设所有符合条件的有 5 笔
; y }. e4 ~) Z+ ]$ a有时候回传 1 笔,有时回传 3 笔,是不固定的
/ K. m- q! Z3 k! l A6 B回头查语法定义
: W8 Y( J# J& S. z+ F$ [; mwith 8 U0 G' G. j5 Z/ l6 R) T3 K
agentset with [reporter]
1 p5 A w) |: L( ?6 n0 aTakes 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.
" e+ w2 f8 Q( e" n w# M. L它只说回传 agents satisfying the given condition
7 i3 B7 V; j& S+ J# F) m/ ^9 ?是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? ( L! z3 S n% j
1 Q0 f5 x! @ c5 |+ ]! T. t
想确定一下
9 x+ @% r, }, Z谢谢!) I7 @) V! e c( D
|
|