|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序- x) ]/ B& H4 D) C' K3 o% |- _
其中有一段如下% R3 h# x3 J% u! s+ j' X
ask turtles with [ infected? = true ] O" ~' q2 ]7 c& G7 a# `' \/ r' i) f
我原本以为这句会回传『所有』infected? = true 的 turtle
2 h4 m6 w4 P ]但看结果似乎不是这样。+ J* }) X, k' W8 G
5 q/ q' Q; ~8 p假设所有符合条件的有 5 笔. F5 ?% o3 s0 M! ^* S
有时候回传 1 笔,有时回传 3 笔,是不固定的# f5 }6 S( x4 \3 W6 H L/ r
回头查语法定义/ f1 C% ^. U$ y$ a
with 4 M C- `! N. F3 s
agentset with [reporter]2 k1 H X& @( h3 t
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.
, m% ?8 Q* C' q/ Z w, t; w它只说回传 agents satisfying the given condition' w& J& I% g0 ~& T) K- o
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? ) K) |" L- M3 N+ n
1 U5 ]& t; ^0 w1 h% U% i
想确定一下
# {, O: _8 j" r- Y$ N8 ]: u" f3 S/ R谢谢!1 F5 B7 O0 F, S6 \; a+ p
|
|