|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序/ K9 i: g- P- I# m; [9 n: i
其中有一段如下& a, Z. W- A" H
ask turtles with [ infected? = true ] O& i3 Z5 K& Q3 [0 }* m+ e" |
我原本以为这句会回传『所有』infected? = true 的 turtle- n- |! k7 u/ e
但看结果似乎不是这样。
( c/ I$ g: s/ d7 W4 X- G! b% C8 z4 Y% H1 x: z* \% `. J* A* @
假设所有符合条件的有 5 笔* S6 |+ [- b% |8 _. \; y+ b
有时候回传 1 笔,有时回传 3 笔,是不固定的0 S8 Z( X2 Z; Z4 r- t
回头查语法定义# ]9 }7 T3 t1 f/ a5 U4 ? _3 E) P
with
3 V. L+ b( h0 U7 Z+ O) f5 Cagentset with [reporter]
, d; Q* m9 {+ W0 o: v! d' QTakes 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.
J I- V: a7 W/ }5 n& X/ M* g它只说回传 agents satisfying the given condition* K6 x* L6 L' r! n, P/ K9 O, B8 Y
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? + f2 w) [7 X0 P8 T* d
( V# [' f% |# a0 d
想确定一下
% P7 y& u: Z1 O1 @谢谢!
9 u" L0 V3 D5 O |
|