|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序! w" u* [% ]2 K& r& n, }' Y
其中有一段如下
4 J3 \( ~0 Y' j4 S6 n! ?2 v" |ask turtles with [ infected? = true ] ! \: p5 s7 [, B% m, G S& k
我原本以为这句会回传『所有』infected? = true 的 turtle9 H6 m: U4 K2 W5 g4 @
但看结果似乎不是这样。
. W% J% |* s' Y
( E2 o2 `. m+ [9 L. i假设所有符合条件的有 5 笔
2 I7 A* X& S% E0 q( f有时候回传 1 笔,有时回传 3 笔,是不固定的+ f# v$ d2 _( [) w2 X* W
回头查语法定义
. k/ A( l$ R) \2 q( ~6 |with 8 N4 `( d* j- @1 o6 S9 c3 L
agentset with [reporter]1 i/ F9 A4 y7 R9 O, ]
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 _. C1 J- ]它只说回传 agents satisfying the given condition
, x! R @( e7 i2 W% }) Z是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
* D, F. e' S3 V7 u$ T# x( u3 { V2 m; S" ?) ~# m
想确定一下6 p" i5 H# v4 ?/ Y
谢谢!9 `' P" A8 [; [4 K' n/ ^1 F; u
|
|