|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
2 ?7 n3 ^2 L0 [. d9 h, S# |2 R4 _其中有一段如下 I o) U* l0 P* e( v) o
ask turtles with [ infected? = true ]
9 B2 M: r6 I$ B6 E我原本以为这句会回传『所有』infected? = true 的 turtle
P0 _8 ]; j0 D& Y, G. g+ T但看结果似乎不是这样。6 ]' [6 n- J' v6 Z2 t3 F/ Y
' E# z- I& [5 H% Y1 Q( e% B& r" J假设所有符合条件的有 5 笔/ N7 a$ d& ]8 z$ ^' I( N* n o
有时候回传 1 笔,有时回传 3 笔,是不固定的8 u4 x2 n( t2 `7 T2 W) Y0 \ o) x) @
回头查语法定义+ c& m7 E5 { s: H9 m6 D/ g% U) ?) v
with ! w# G( ?9 n2 O. k9 c4 `# Q
agentset with [reporter]& D3 n. _2 V/ x" T! H {* \& 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.
2 }3 ]# F y3 k它只说回传 agents satisfying the given condition% W; |% i% E/ M" ?5 `6 S
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 0 ^ d6 y' I& P
0 z3 O0 [; b% f+ n. `8 w1 d8 m5 [2 E
想确定一下) T3 n; u. q- u2 ^0 w
谢谢!
& e' {8 x! n/ U7 U; u1 m, W& ^5 b |
|