|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
# L( N' Y2 w/ H* l5 z! W其中有一段如下% z( k* a' ?- y6 l+ ?' |# O% d
ask turtles with [ infected? = true ] & z2 D& a: k( U/ ~0 A/ h: s( u
我原本以为这句会回传『所有』infected? = true 的 turtle5 C( k& C* l$ O
但看结果似乎不是这样。
( h4 R. A7 V& c. H1 m4 A5 m9 A" s, a- Q$ _
假设所有符合条件的有 5 笔$ N& S* e0 f% m2 [( w$ T
有时候回传 1 笔,有时回传 3 笔,是不固定的
1 _8 T8 Z2 ^ b, u3 V" J回头查语法定义" H* J. C% B$ d7 z5 x
with 9 }7 u {# @# B" \; W1 Y# p2 r1 t, v6 a! g
agentset with [reporter]+ U. s& I) a5 }, b. z( S
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.' P. L) F7 U8 F( ?
它只说回传 agents satisfying the given condition8 r/ ? {6 m/ X" N, D# [% S0 }
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 0 A4 Z: W6 v& I1 Z" a" d
# R0 k1 B* ?+ w6 l" k2 P想确定一下
' ^/ @+ n# X H$ {1 F P谢谢!- H% c* Y; Y, H0 F. L
|
|