|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序; E/ y; G# { T7 G2 |' I1 Y+ ~. [0 h
其中有一段如下
; u* j, P% J- T& F* T% @0 `ask turtles with [ infected? = true ]
+ i- n! Y# M& l我原本以为这句会回传『所有』infected? = true 的 turtle
5 Z! c: s/ Y4 Y- Y: m7 n但看结果似乎不是这样。! U% y, Z3 k" a/ z
( h+ T# T( n9 `, [& M1 W) H假设所有符合条件的有 5 笔
5 g0 A$ R% @4 j# N }, g有时候回传 1 笔,有时回传 3 笔,是不固定的! G/ f; d% s& M" [$ V1 K
回头查语法定义/ X! L4 w$ g, u6 O: W+ r
with " q' K6 d7 P! j7 z& z ]( U
agentset with [reporter]) _8 n' A" f) M) N6 S% K
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.
3 L" w5 l' |2 B2 ]它只说回传 agents satisfying the given condition8 t6 y* o# N1 X5 ^1 n) j( u4 `+ x
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 5 h4 ]% I# `0 u; i7 }5 `# L4 o
0 z! e" s. b; _1 k
想确定一下( \- e; C( v& Z4 H
谢谢!
+ U, {8 p) K$ R1 n, x* D& n |
|