|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
; V8 L* B) O5 G( i: I其中有一段如下& p% E1 F. A4 K% c- s
ask turtles with [ infected? = true ]
! p9 k( A7 N9 @) }0 U, n; S, W我原本以为这句会回传『所有』infected? = true 的 turtle9 ^" c# o9 ?* B+ f
但看结果似乎不是这样。
% P/ d \3 l% B3 v! X) x$ }9 y" y0 J: n, V3 e. q, i
假设所有符合条件的有 5 笔' w# p6 W/ o9 ]5 P$ j7 P5 }
有时候回传 1 笔,有时回传 3 笔,是不固定的8 C2 b& r, a& V+ y( T7 T/ U
回头查语法定义$ o) Q7 K; v+ N! ^- h: h9 _! J6 I5 ?
with & m [: ]" u/ C; E" B9 |
agentset with [reporter]
+ M" \8 B6 G( v2 _. Q# ETakes 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.0 |6 N2 \ t0 L+ Z1 C1 M2 ?
它只说回传 agents satisfying the given condition
1 {( f/ Z& I8 D) ~是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? % `9 {8 `+ Y9 C/ J& n
7 j2 |# [' ~% D+ s* M) ~
想确定一下
~. n9 g9 s; Y6 ]# G- x谢谢!9 C/ R- w P! E) }; b
|
|