|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
0 t+ P Q6 B& |& [+ b其中有一段如下! d) D" \! N9 X: N9 w# i" @
ask turtles with [ infected? = true ]
! s# Q' Z. Q3 e我原本以为这句会回传『所有』infected? = true 的 turtle
3 F/ |# n# z4 o9 Y% X) Z* k+ J但看结果似乎不是这样。
: b' S+ o/ D* O1 d! k! n
" F X* @* p) h- ? H假设所有符合条件的有 5 笔
( W- S* V3 i( @4 U' H1 [2 t5 p有时候回传 1 笔,有时回传 3 笔,是不固定的& n- U/ s$ J- w9 _) O; m
回头查语法定义. V/ V$ y# Q4 c2 c6 l
with
, w. M& u, c' ]) T% ?4 Qagentset with [reporter]
. n+ G0 c+ m& {( `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 _; I1 u, C0 E4 ]0 N
它只说回传 agents satisfying the given condition
% M4 c2 {5 R2 B: o1 J是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
1 v" k3 i. v8 h; Y5 D7 a1 n% \% d; n+ `; K. g0 K: n1 J p
想确定一下
% d$ j9 G8 m% x, Q8 m) X谢谢!5 b' ?' C, D% y& A5 \
|
|