|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序: h3 A. f; z7 B- @# ` W( Q+ c K9 J
其中有一段如下
, }0 ^8 H: J! O1 a3 M! ^ask turtles with [ infected? = true ] 1 |' t' J% x, A+ L6 K8 t& P
我原本以为这句会回传『所有』infected? = true 的 turtle7 @8 c# t3 g! |, p
但看结果似乎不是这样。
7 o# I( }7 [& u1 R+ X
9 j7 ^+ o, @2 v9 F7 P假设所有符合条件的有 5 笔
$ `8 A2 l% G; T" S; Z# u有时候回传 1 笔,有时回传 3 笔,是不固定的0 J/ Y4 n8 r7 s
回头查语法定义4 l3 L' {1 n1 S. \, d
with # D( o, w4 \) y% b# P/ ~
agentset with [reporter]
* b0 S# s8 P% `& D; vTakes 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.( ?/ m2 E) o( E9 p6 i' }& i- u
它只说回传 agents satisfying the given condition8 Z7 E2 f h1 Z6 _# I
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
# D; R' _* ~& Z' i5 N) X/ y+ W, j& Y) C: {" R$ Y' r3 Q
想确定一下2 E _; {' `# x$ V2 c
谢谢!
# r+ x6 `" s" B6 L* C |
|