|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
$ y* n9 k: U( N, r6 N其中有一段如下: s: E4 W: _* B% ^& {. A
ask turtles with [ infected? = true ] 8 l1 S( R, [% \% _
我原本以为这句会回传『所有』infected? = true 的 turtle
% A% s$ _# Z" |但看结果似乎不是这样。
6 h& g: J4 a4 V1 g4 z2 p# K- s
; E3 J) G( R5 {) I, a* g) S3 ?假设所有符合条件的有 5 笔
) X# A1 x, F" K' I! X! J( n有时候回传 1 笔,有时回传 3 笔,是不固定的% @6 J- `6 {7 e0 y& Y+ t
回头查语法定义
; B4 x# w% A& V& uwith ! j/ D3 N7 S8 d% o$ w# J
agentset with [reporter]6 H# Z a3 F' A/ j. A. |, 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.8 j Q4 h! h2 d2 r, V7 B% U
它只说回传 agents satisfying the given condition
( k6 u W5 `+ g3 [是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
8 q$ U# f, u' v6 ?! J1 i& m
; g; N# Q+ L) w O/ |想确定一下& y: s9 G' O9 L/ a( A
谢谢!
! N! Z+ E. h# o3 |7 q/ d |
|