|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
! b* y( N g4 D. R其中有一段如下+ l; F1 r; l5 w8 M! r" a+ V
ask turtles with [ infected? = true ]
; U& O3 W# N) z2 X! |/ a我原本以为这句会回传『所有』infected? = true 的 turtle
7 u. A; v. k/ T3 b7 _# @: J: N) Y但看结果似乎不是这样。
, B- I; Z1 f0 ~2 f7 N/ ~4 n$ X6 [3 f+ d: Z3 {& @% p. e
假设所有符合条件的有 5 笔9 @) J4 ?, R. t; r9 y8 I/ j
有时候回传 1 笔,有时回传 3 笔,是不固定的
L0 z; {: |( e, d C" \回头查语法定义' f l- h6 \+ I4 @9 v! n
with - N) z) v' K: S8 O
agentset with [reporter]
: V1 @$ A& I2 I$ g5 {* fTakes 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.; F+ W% G( p5 N) @$ z
它只说回传 agents satisfying the given condition
$ @1 j: ^5 n" d是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
. M' J9 N% n. f6 h! K% x( n1 v6 w9 c3 e. ~
想确定一下$ a! G# \" {% A+ U- \5 H2 |
谢谢!
. n0 {7 |. Z2 o* _) r# j; b7 I |
|