|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
: d/ }' G5 q1 R @; F$ I/ R- t其中有一段如下
) a& j0 J* J5 f* _ M6 `ask turtles with [ infected? = true ] 4 x0 V3 ^: x( s0 L! S* H
我原本以为这句会回传『所有』infected? = true 的 turtle6 S6 m+ ~& d9 K( c( r
但看结果似乎不是这样。) I' ^0 G5 D( X6 S3 ~
+ b; E$ N* ~/ Y; R! g5 z4 N假设所有符合条件的有 5 笔1 H6 v) U4 M' D; n4 ?
有时候回传 1 笔,有时回传 3 笔,是不固定的
( F' v* D, S, ` m. u4 f$ f( {5 ^. f回头查语法定义' D, H7 |1 ` h4 m
with * e8 u9 j0 K0 Q% j: }
agentset with [reporter]
5 q# C) `/ ^7 X+ @* U& h" rTakes 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.0 c" v8 s% m8 A
它只说回传 agents satisfying the given condition
7 j9 U. @) }% X3 x+ V是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? . q; C, X7 a+ g2 i
" G) s6 p6 M" `9 a3 Y4 x. c j想确定一下
6 @' I+ P/ Z$ R# H' L s! o, v谢谢!9 A$ m- v+ ?) f
|
|