|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序6 }; }, ]: X/ T) T9 Z- w- {% [1 ^, ?' O
其中有一段如下! s2 _5 \; z u3 ]9 m
ask turtles with [ infected? = true ] # y) @7 ?% g; l4 N$ m- j; y9 O
我原本以为这句会回传『所有』infected? = true 的 turtle- t( v. }6 z, A; ]
但看结果似乎不是这样。
4 Q! I |5 M6 L, D6 A2 g7 d- x. t$ }& z- j. n1 t$ {
假设所有符合条件的有 5 笔2 Q, G% K+ _. B
有时候回传 1 笔,有时回传 3 笔,是不固定的( N( x3 I" |! y! u; W
回头查语法定义
# e$ w& e* P9 y) Xwith
1 j: J, H: a Y2 U( B0 ^. p; Kagentset with [reporter]
{; `9 l7 w. I: u5 H# w, P. x4 O& P3 `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.9 B7 V$ X( K4 k* U. ^4 q8 Z8 q
它只说回传 agents satisfying the given condition
8 @) _( Q- D# u9 M. h是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 1 r2 F, Q- H0 O4 s" t5 H/ ~
9 b- e4 M: s: r# }想确定一下
$ V/ D4 H C/ n( w. X+ D" ?谢谢!! h- G2 P$ `) P+ }
|
|