|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序 ?/ l0 Q- a) C% o" Z8 v
其中有一段如下, L' R$ V+ M+ L9 `* a
ask turtles with [ infected? = true ] % \2 X. m) B9 _3 W; U! L. h# V* v0 K
我原本以为这句会回传『所有』infected? = true 的 turtle
% z3 _) S8 v* c但看结果似乎不是这样。
) `4 H' O n4 }- P& I
" q" J! b# H) @5 i假设所有符合条件的有 5 笔
) p& E2 c/ R: E6 ?; D9 C有时候回传 1 笔,有时回传 3 笔,是不固定的
6 {. R3 q. w7 {$ ~" l2 S' }回头查语法定义 c6 D# D6 j: O" ?' |8 n
with 1 z2 _9 A/ g$ d& E5 X
agentset with [reporter]6 Y M* [1 `! P" {
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.
& ~! ?7 ?9 _# f它只说回传 agents satisfying the given condition# _. T6 _1 z7 a" Y; \
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
0 m- {# ^7 O5 q3 @* C
5 g3 Q3 Q- E! t5 r1 ^0 e+ o6 @2 Z想确定一下6 b" ~6 u# m1 e- ?- ^
谢谢!
* N, K- |# J, t) B |
|