|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
9 U/ }) ] ?9 p# C9 t其中有一段如下+ p5 D3 d4 J8 ^! i4 b8 n
ask turtles with [ infected? = true ]
" H6 t0 U' @9 F9 h& T3 S我原本以为这句会回传『所有』infected? = true 的 turtle
0 O d* c' g$ W3 A1 l" _但看结果似乎不是这样。
4 B$ e' h$ d8 Z, F2 ^
8 E1 n* x% n& i y$ I& `( }假设所有符合条件的有 5 笔% j, p" \0 Y2 Q* ^3 k! x
有时候回传 1 笔,有时回传 3 笔,是不固定的
9 U$ ?8 l3 ~; Q# Y X回头查语法定义$ i2 d5 A$ u; Y; e* O
with 6 L- X9 Z; J# t
agentset with [reporter]
8 a w; [" i+ ^3 p2 n7 G% ATakes 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.4 K J/ ], Z4 T2 B
它只说回传 agents satisfying the given condition
: V+ ?( v# F6 d" l9 O0 s4 d是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? , \1 y' f# D! S6 M0 O& D4 O0 ?
+ \, h. g2 E1 R" O3 T/ {( n4 O) W0 h# [
想确定一下
( |3 `, s2 h9 m: {* A谢谢!' n" @% _# h8 Y
|
|