|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序3 g* N( `" i# F( Q2 G( W+ E
其中有一段如下 D e( H4 P8 c+ j0 k
ask turtles with [ infected? = true ]
6 r0 m9 h v% N, ?) S& O! o我原本以为这句会回传『所有』infected? = true 的 turtle9 S! `1 K& M' N d
但看结果似乎不是这样。 Y3 ]( b/ ]- X- M4 \
8 z0 r N/ n d& K
假设所有符合条件的有 5 笔$ H; R; r1 F& p' c# ]
有时候回传 1 笔,有时回传 3 笔,是不固定的
2 W3 Y0 V; C. L: V* N8 z2 i回头查语法定义
- g* R5 L* B- y; h7 pwith
. M, H5 X& q5 M! E2 @" bagentset with [reporter]' a8 b0 O+ y6 z1 z/ N
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.
" w9 u3 r% J" `+ P( S它只说回传 agents satisfying the given condition- b) O) E0 q3 H( K; {
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 5 c u: S3 o5 l8 v# W
( d7 v1 A# e9 I6 A! Z8 A
想确定一下
! t; W% i3 K* E D. U谢谢!; Y' d* D5 M# w. |
|
|