|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
/ H; { M! [8 A- f6 ^' O8 a/ X其中有一段如下( S# M) i" } Q$ ~% M: n) U! w* {
ask turtles with [ infected? = true ] - j) P& F; w! I1 _3 j
我原本以为这句会回传『所有』infected? = true 的 turtle
3 I9 O0 j1 f( i) Z" H; q8 `但看结果似乎不是这样。* y9 |* U* M: I5 t. v2 K7 P
1 [) g+ d5 Y3 E# V# S6 ~& m8 G! X9 ^假设所有符合条件的有 5 笔
% V! u* _: V: i3 n3 a! Y' r7 J有时候回传 1 笔,有时回传 3 笔,是不固定的! {) M( T# x5 F
回头查语法定义7 }: q- ?) @0 ~7 p2 }9 d) X0 Z
with
' B7 j3 s! J$ y0 R# B+ Iagentset with [reporter]! g7 W; {+ m9 ~- L- Z# t' Y0 `% X
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.4 w+ B$ d1 e5 F7 F
它只说回传 agents satisfying the given condition' ~6 L' e* r, G" T# F; [
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
* O5 S% h5 u6 R2 \6 k1 Y& k! j* C. q) I9 J- ]2 v
想确定一下' _, _6 w' r# q% n( d- `2 p0 \* v
谢谢!
; H% J* @1 ~5 c |
|