|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
1 \9 Y& K7 U9 Q% N! B" `! _9 m- S其中有一段如下& D4 ~' M6 h9 U; g/ Z( x- \2 E
ask turtles with [ infected? = true ]
# Y% q" P/ b* l+ o我原本以为这句会回传『所有』infected? = true 的 turtle; D% l% q$ R ?
但看结果似乎不是这样。. U1 [9 R3 R$ X# Z( E: v* N* ?
, Y8 J1 c8 k* `# ?( h0 a2 q: O假设所有符合条件的有 5 笔. ^! u" |, U0 j# _) l) b; I
有时候回传 1 笔,有时回传 3 笔,是不固定的
5 i% o H+ O2 r3 W; k+ t3 Z7 M回头查语法定义4 I6 P& e; l+ m
with
0 N7 ^; Y4 ]3 ?& S$ z/ K0 m2 {/ Iagentset with [reporter]+ F. Y/ ^8 E n3 v8 C5 |
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.
8 c* m9 V$ y+ Y它只说回传 agents satisfying the given condition
; t+ l0 x. e/ R6 N& y5 b0 @是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
; f0 ]7 [' W2 z O# |+ v. ^* q2 x4 r, z3 e* G5 E% C
想确定一下6 P+ r6 w" ]- ^; D* M
谢谢!
: }* z; d3 j2 A7 v, S0 T |
|