|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序$ e5 l. v% b; y. w' p- \+ \+ m5 x3 D
其中有一段如下1 h7 _: l+ H, Y9 F/ B
ask turtles with [ infected? = true ] - J& H0 o4 W8 j1 x9 `5 w+ ^7 _
我原本以为这句会回传『所有』infected? = true 的 turtle; E3 U' }& b, e; [% I9 v
但看结果似乎不是这样。; I( c. x5 i" Y
" p) ^. W# Z5 \+ w4 Q" l假设所有符合条件的有 5 笔: v% d* p5 V9 _$ K/ m. T( a
有时候回传 1 笔,有时回传 3 笔,是不固定的
: U* R% O2 q; {$ h* H回头查语法定义
9 F5 b7 u9 W6 F* F% A8 X# Pwith * l2 p! l5 w& _
agentset with [reporter]" Q' P0 _2 e$ a: ^
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$ ~) j( K3 u5 x, U它只说回传 agents satisfying the given condition
& x& I" h3 i' p: x w是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? ! `5 q7 V& m' @1 Y9 x. S G
8 r2 p' H$ b& B+ k6 n2 |
想确定一下
) j( Q2 f) \" T& e" R谢谢!
1 G4 l0 i6 d7 t% o8 t2 s5 T. _) H |
|