|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序/ D: N3 a) T# }
其中有一段如下) [$ W& y. e$ w! p
ask turtles with [ infected? = true ] 1 v C& }; @5 {' Q0 D
我原本以为这句会回传『所有』infected? = true 的 turtle/ n; [ d+ O/ z* @
但看结果似乎不是这样。
2 I, a9 w) R0 k/ X0 M" B. t" p2 _ J, s7 y
假设所有符合条件的有 5 笔
) C2 G+ }" v* ^% H有时候回传 1 笔,有时回传 3 笔,是不固定的
! F' z: w3 }( I" T& [- q a: y回头查语法定义0 ^- c' X8 b0 t* U( T
with ) {* v8 A9 G; S% B F, E
agentset with [reporter]
9 H, }# ]5 q2 A2 } R: sTakes 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 I9 P5 Z" `* a它只说回传 agents satisfying the given condition
$ D3 C+ [0 b5 A& H0 g! _; a是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? . J1 D- c, x M: `
4 ~+ T+ K/ i6 l% t* m& g
想确定一下
5 L- L& M/ f Z5 ^: E& f0 S" w g谢谢!1 E( b3 u8 `$ |1 V
|
|