|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序 K I3 w: G! q" S8 R' J) }
其中有一段如下
, [! ^5 _4 r/ Z3 U( Iask turtles with [ infected? = true ] 9 g& X/ O: ~' V5 e2 Q$ o9 W4 k
我原本以为这句会回传『所有』infected? = true 的 turtle9 i+ u1 {0 e( |# [
但看结果似乎不是这样。5 k5 Q. a4 `5 S9 c, _. M
" ~* a t) w& R. ?# \) Y8 X+ k; b
假设所有符合条件的有 5 笔& t6 V; u! Y+ q
有时候回传 1 笔,有时回传 3 笔,是不固定的
/ |; u; c) @/ d+ x' w6 F+ \回头查语法定义
6 p# L9 h0 A1 o% ywith ' k$ O# _) H1 K. n) ^) M G- Q
agentset with [reporter]% v1 X+ i( g3 d5 |2 E
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.
4 w+ D- R' q7 x4 I0 a4 t7 L它只说回传 agents satisfying the given condition5 e# Y+ z- @6 ]& l* q& S8 C- u& R
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
8 `& j& y: Q5 O5 i
0 m+ B% L# z; x* _ N0 C& E想确定一下$ K# X0 _0 k. Q4 F6 O
谢谢!
5 o- Z$ C& I, f T6 C7 L5 @) s |
|