|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
* Z8 F& j/ s5 U) @+ E3 j其中有一段如下# N; ]( p, D$ N# B" @! f
ask turtles with [ infected? = true ] % W* e2 L4 X. C5 L+ S3 L& N
我原本以为这句会回传『所有』infected? = true 的 turtle
; v* e5 f# f9 N& T: r: q但看结果似乎不是这样。
2 K7 \$ @7 ]: F; \* h$ E- \' G
0 E/ x4 ]2 i `- J+ E假设所有符合条件的有 5 笔
6 p W& y* D! t+ l- c' i) a有时候回传 1 笔,有时回传 3 笔,是不固定的6 L* e: H# E% Y, @' p
回头查语法定义; D+ o4 U7 O* _0 w# G: E
with * X4 w3 |5 w% A; b- H; y
agentset with [reporter]
. {+ P1 O7 G( i) yTakes 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.% t3 T# z2 I) p
它只说回传 agents satisfying the given condition
# r7 E H8 U6 ]* Q B是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? & h7 m, ~5 O; x1 Q1 O
! R4 G: w2 a3 X5 L3 T# L
想确定一下 W# E& E8 T% r. d
谢谢!
, g# ~( T# n* A+ b, D1 n9 N |
|