|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
* f' n6 X1 Q! x2 K% {其中有一段如下% Q8 H- y) d$ R# v, j
ask turtles with [ infected? = true ]
5 w: z6 @( u: b/ }) O我原本以为这句会回传『所有』infected? = true 的 turtle
9 e! a/ I _1 d: b6 n$ F* U但看结果似乎不是这样。
5 R+ ~ q. k; Y
0 l9 q! [+ ]9 e假设所有符合条件的有 5 笔 {) x+ n3 \6 C; X* \% @
有时候回传 1 笔,有时回传 3 笔,是不固定的
" S$ T0 P7 T% P回头查语法定义
& k- w! G5 B K Q4 ewith
3 c- Z/ X. e' fagentset with [reporter]1 B6 D |. J$ Y$ I/ X6 ]" b' f) {
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.
+ X$ J' |2 E0 |! K% z( e2 ]它只说回传 agents satisfying the given condition/ u3 E; u6 G/ f, A- U" f
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 8 A* N& o7 ?; e- m% |
$ J4 E8 @) p2 F% `) |2 s ?
想确定一下$ J8 g7 o5 n9 K0 p! H
谢谢!
( X G; w/ `! L5 G! O# g ~ |
|