|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
/ J" h9 R0 _/ l: V# c0 q" P/ R; u其中有一段如下 y3 o z8 e! v2 U9 A- F/ _
ask turtles with [ infected? = true ]
# ]: z# E& C$ B* F% e& }我原本以为这句会回传『所有』infected? = true 的 turtle h5 x: h0 e3 i% |' D
但看结果似乎不是这样。
9 X, d: H- U6 Q6 R9 z9 v4 ^
$ J; Q2 M3 ]. H/ a9 r5 e* o假设所有符合条件的有 5 笔3 N3 `1 t3 A( t: S ?
有时候回传 1 笔,有时回传 3 笔,是不固定的+ i1 {$ c1 E! F; j. ~8 h
回头查语法定义* C$ n1 a3 v. J8 t
with 1 V8 i q% I* k4 E) B$ F0 q
agentset with [reporter]
( I; ~6 ?7 S2 R/ Y1 E" W; R9 b. uTakes 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.
) o1 s* U- F0 [ _- U( w. q: W9 _' r它只说回传 agents satisfying the given condition
% w9 w3 p# o# {! A k是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
; r4 F6 d0 O" g# R5 T! a3 k7 q: y9 @- d; i, U# R# T% F
想确定一下
' r) L$ N2 ]- g7 }. k. m8 {谢谢!5 A- X, g) u3 l8 M8 i! ?; m$ W
|
|