|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
5 g; g9 \/ o7 T5 F3 c其中有一段如下; v6 }$ J5 f% h
ask turtles with [ infected? = true ] 5 ]2 Z9 S8 h6 D* K X2 A
我原本以为这句会回传『所有』infected? = true 的 turtle
3 E! R& Q4 U. J. O4 P y! |9 z9 X但看结果似乎不是这样。
, ?1 `$ b& W1 T/ A! d5 D0 u
0 k* r. B; B2 w3 v假设所有符合条件的有 5 笔
/ ]& v& q, Q) x B) U1 J有时候回传 1 笔,有时回传 3 笔,是不固定的% o( G# u1 n$ d
回头查语法定义
9 u2 z0 I- c8 x5 H4 M! k( m. fwith
1 B4 j, v. e7 R: h N8 zagentset with [reporter]% w/ o" u. K3 ]1 B% }8 G
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.9 t+ J' Q! A7 i& r& x" m
它只说回传 agents satisfying the given condition9 e. A+ T% H- q. ~* b+ N
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? ! O6 A+ |2 U0 e! _+ E4 c
, Q; ^- K; s0 i( a* ^
想确定一下/ D2 j% g2 Z: \: V8 u' K) ?8 s
谢谢!+ z9 g, I r1 M4 q# _
|
|