|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序. h% _! p- D6 z3 k$ M
其中有一段如下& \# y/ E6 L f
ask turtles with [ infected? = true ] 7 O. [/ T$ T+ Z8 x
我原本以为这句会回传『所有』infected? = true 的 turtle4 A; V# N: e/ S% y$ H
但看结果似乎不是这样。+ P) C1 U- f: x1 W; p5 K
6 k9 H+ J/ E; I7 x+ D2 N假设所有符合条件的有 5 笔 j- j6 m( x: z% i+ F% `: ^% V
有时候回传 1 笔,有时回传 3 笔,是不固定的1 G$ F0 ~4 P* ~0 E9 g! j
回头查语法定义3 J5 J* O7 ~) d! p# z, G& Y: \
with
' P# T/ {! a5 }agentset with [reporter]( i& W0 k* J: V( F8 s% D
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.8 W" X) u! A$ C/ v* [0 \# y
它只说回传 agents satisfying the given condition# M H" M9 F3 w; F+ L2 ~
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
/ O# I1 ?, t: L7 b/ Z* q6 a& g. F: t6 U9 h
想确定一下, b8 ~5 f* A& u8 z; J
谢谢!+ _$ N5 Q! ^0 F( Z
|
|