|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
& D6 B; ?! W9 f; @( u! X2 ^其中有一段如下# g# K. D2 A& `7 U: [. {
ask turtles with [ infected? = true ]
9 O! a" w |2 N% E, o我原本以为这句会回传『所有』infected? = true 的 turtle( Z- h5 Y$ b Z9 J# \& b
但看结果似乎不是这样。
' k1 m" V1 A3 G* o; m: g) L9 s' g
9 j0 Z+ I/ o4 R$ \5 [假设所有符合条件的有 5 笔
+ q8 K' x# ]: j( L- h( c# e有时候回传 1 笔,有时回传 3 笔,是不固定的
4 d: [) F& ^) F, ]0 C回头查语法定义# q& J( c. Y( I5 {7 g# E. A4 k
with
8 ?1 ? B$ l( K, w7 I- a0 p Tagentset with [reporter]8 n/ e" W p( a5 y" B" @1 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.2 c1 t3 T% O6 J/ V; q8 y2 m6 @. w
它只说回传 agents satisfying the given condition* E1 b3 v4 B7 p5 C* _/ u8 l9 p9 \
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
) R( ]; h$ x7 q: ^$ }! P4 R7 F6 p" l
3 ]* S/ N$ R# W4 A8 o0 k' U想确定一下
! `* N5 j1 R* X6 \' ^& t; \& f谢谢!
! R* Q8 d5 z2 v8 ^ |
|