|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序- d" F5 g" f$ @+ J9 K J
其中有一段如下# X& h! K% Q7 g3 F: y
ask turtles with [ infected? = true ] : d; {+ t2 [/ K- g( K; U
我原本以为这句会回传『所有』infected? = true 的 turtle
9 F! e9 ?5 F5 D* G6 u% S1 i# v但看结果似乎不是这样。
5 m1 Q# j0 U+ y) M
1 f" E) \8 s ?; X假设所有符合条件的有 5 笔% L' {' Y6 S& D) ^
有时候回传 1 笔,有时回传 3 笔,是不固定的3 a( a1 Z- B* x) a' x1 _9 R& l
回头查语法定义; e+ p5 y' q# S( g! n
with 1 m5 Q2 c, v8 @3 [ B1 c' ?
agentset with [reporter]
* y: N. J# @( `% V1 Y5 HTakes 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.. K- R/ @; ^7 Q3 S) ~2 `" p; D G
它只说回传 agents satisfying the given condition# k8 [" {% Y" H* k$ I
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
0 P6 y8 m3 p2 h. x
4 x0 T. q& g2 m, P3 D想确定一下5 S$ n" ^9 \- ^2 i* y# [: B$ y
谢谢!
N% V& c+ E: y$ O6 a: y9 h |
|