|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
$ P) P! D3 u) I/ K' ~其中有一段如下# j& z- ^+ U: v
ask turtles with [ infected? = true ]
3 }- Z/ P/ {9 S我原本以为这句会回传『所有』infected? = true 的 turtle2 ?9 H" ^" f. e' @9 P8 g
但看结果似乎不是这样。
: @ T% c8 e' s& z
6 |6 z$ O/ p" u0 G5 v假设所有符合条件的有 5 笔4 Y! o* S& h! f: J- e* Q+ e* T
有时候回传 1 笔,有时回传 3 笔,是不固定的1 Z8 ^( g( \7 }. X5 i, D0 [+ y
回头查语法定义8 K+ Y, W- B9 O# v
with - l' F+ @& w* n
agentset with [reporter]. `% Z# y2 K/ p! F% \7 H% c. e0 [
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 K' J4 F. x9 `4 L5 }0 a6 [( A# m6 u2 b
它只说回传 agents satisfying the given condition; h- G" Z) e! ?0 g4 _
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? ) U [/ T. c/ a) l. Z' b
7 n; @" B6 V$ x* o) l) ~想确定一下
/ {) R6 g; d5 v8 @( ?谢谢!
0 t( K6 Y7 N, }, r+ U( V0 U |
|