|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
- m0 z8 v4 T2 q其中有一段如下; q, F: ` J5 V. p
ask turtles with [ infected? = true ] " Y" t8 C, M, h) b
我原本以为这句会回传『所有』infected? = true 的 turtle( }, H. `8 w( |6 Q, V* Q2 y
但看结果似乎不是这样。+ n _; j/ Z' H; t
% G" B7 _+ h; `- S* {5 G
假设所有符合条件的有 5 笔
9 [3 a7 b8 P% u5 X: J有时候回传 1 笔,有时回传 3 笔,是不固定的: D4 L! s! D# R! y. z
回头查语法定义# {* X! |% G" Q- M$ F- n. r+ y* m% P
with ( z( `1 m! d& p) i! | j
agentset with [reporter]/ ~/ g8 ^$ C- X/ b- D: 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.+ ]" `3 W* N- r
它只说回传 agents satisfying the given condition
& |% S, _$ A, ^2 ]4 u' H3 ]# _' W是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 5 ^, x- _6 m# i; H
6 }7 A4 W: k& V( F+ n
想确定一下
; F( o0 U) m# r! O3 i4 R* i7 r, W谢谢!
$ Z% m& p4 B1 R1 d3 [ w2 O @ |
|