|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序$ x5 b# v+ G2 O7 V; p7 H
其中有一段如下5 ?/ A4 ~! C; }( o7 X7 R+ |8 ^
ask turtles with [ infected? = true ] + E7 d1 N; l, C" o3 w
我原本以为这句会回传『所有』infected? = true 的 turtle5 g& _$ F0 T& s* [& w9 H3 U4 ?& r
但看结果似乎不是这样。: Y9 _& J D' `
% h( n! a* ?" ]
假设所有符合条件的有 5 笔
+ M. o* z) m$ [; i# b有时候回传 1 笔,有时回传 3 笔,是不固定的" N4 Z2 q8 j9 j1 W) D3 }7 b2 z3 k/ c
回头查语法定义
4 t- p3 ^$ y k' ?' r ]with
2 d: H' C/ h O: w/ wagentset with [reporter]0 {' H' m" O3 r; P4 m. m
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.$ C0 t7 k$ c8 L/ b. {- x% |
它只说回传 agents satisfying the given condition% j+ P8 B# B9 q3 w: R# H7 D
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
. E* E2 p3 M* O, g" S- R( r' H* u+ {9 \3 s+ P0 e6 Y! R
想确定一下
" C: c. D/ m6 D( V7 x" G8 _$ ?谢谢! D" z1 H: }- R) G. Z
|
|