|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
" n; m2 E* r l2 ^, q& C其中有一段如下0 R/ J0 n# U/ I9 m
ask turtles with [ infected? = true ]
% s* L+ D7 `" u我原本以为这句会回传『所有』infected? = true 的 turtle
: G: M9 ~, ^2 u但看结果似乎不是这样。- ^9 G& V4 K! ?: m: R& ~% T. p
+ G2 `* {, |) H9 p1 ], n2 k
假设所有符合条件的有 5 笔. T, I2 x" C" }- s
有时候回传 1 笔,有时回传 3 笔,是不固定的7 ]7 U* v1 s; ]2 b; e# V
回头查语法定义
/ N' r# _6 d- L% i3 lwith & y$ O. ?: [; G
agentset with [reporter]1 d1 {- h7 k/ x! k0 O; G( j
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.; ^/ I) c2 j( I1 v3 ?+ N
它只说回传 agents satisfying the given condition9 I/ I' B I/ e
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? & u& `* z' K1 u" h
2 }$ |4 B `# r( B+ }# h; Z, Q' R
想确定一下
5 ~5 Q) j# e# ]谢谢!
5 b' J0 g( c; M5 x# a |
|