|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
- t q; V/ \( y3 z( N/ k0 d其中有一段如下4 z& `: s& w# ^0 J X B
ask turtles with [ infected? = true ]
8 I: f/ u' j+ K1 F- X我原本以为这句会回传『所有』infected? = true 的 turtle
) o$ a/ f: i7 X1 v) k但看结果似乎不是这样。
) O8 `9 V0 x- P1 x- U' o( I* j B
+ m: D% g5 N! f, J n+ t! {; ]假设所有符合条件的有 5 笔# S$ K4 t+ X! x6 e
有时候回传 1 笔,有时回传 3 笔,是不固定的4 A( D; F6 Y8 y4 j. f
回头查语法定义. }' B6 }5 ^5 S: Z
with
: x9 v( @6 s0 H$ gagentset with [reporter]5 { D8 t! m$ G5 C( @: {7 v, [
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.
7 N2 W c6 Q/ i. f- o' H/ [它只说回传 agents satisfying the given condition
$ Q. J6 ~# C2 U, q9 a是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
3 O' V! O& Z9 w( B" z, U* ~' y( v ]& N
想确定一下* C6 L9 J% F6 \. N" R
谢谢!
6 v. c i8 K8 v4 J" @$ Z |
|