|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序3 G5 k: E7 ?8 W) g
其中有一段如下+ B2 d1 V, u, w! f6 V5 m
ask turtles with [ infected? = true ]
/ O$ _1 ~) }* R3 B" u4 S我原本以为这句会回传『所有』infected? = true 的 turtle* z! }6 m7 _9 A
但看结果似乎不是这样。! N3 b: I4 T% L2 }$ M
9 R1 c: v7 C: A; H2 Y假设所有符合条件的有 5 笔
1 x/ [) J: o& ^+ n2 y有时候回传 1 笔,有时回传 3 笔,是不固定的
9 d+ g9 g( H" }2 J K# }% m回头查语法定义1 k0 o7 K0 l4 u
with
2 F( e' L% W4 A9 `* o( Eagentset with [reporter]
' M7 i; `$ ` V8 e* G& ^- mTakes 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.
4 P$ R0 ` C1 { b) L& n它只说回传 agents satisfying the given condition
1 G& q' g% Y8 x: {! ? \是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? * [( m0 g$ ^) f. G/ r8 O! K4 s
" Q" C6 e ]6 J: U5 \" ?
想确定一下6 ]% x) K* r* m+ w* b6 t. Q
谢谢!
% d0 \# V' q# ^/ p# c |
|