|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序3 c% X$ K5 U* }) m" f
其中有一段如下
+ I2 b& L. t1 u8 V$ \' Z) Q& `3 m1 ^ask turtles with [ infected? = true ]
# N: j9 u3 I i* q我原本以为这句会回传『所有』infected? = true 的 turtle
5 U C* X/ b# G. J2 {6 J但看结果似乎不是这样。 k# u5 `9 G# O+ V& X6 `
% Z, s2 D+ \3 c- A Q3 A) ]
假设所有符合条件的有 5 笔
$ C) P1 o+ t( R; \有时候回传 1 笔,有时回传 3 笔,是不固定的1 R/ j; y; } S1 e5 i
回头查语法定义
$ x/ n) I8 @7 L+ I; Ywith % }; |9 R6 I3 b* Q; w, E6 F
agentset with [reporter]7 _) Y& @2 P& T# _" @
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.
) o6 b8 }; c# C0 B3 @$ ~- `) x' }它只说回传 agents satisfying the given condition5 T# f3 ^3 w* ?6 C0 Q5 i# ?2 k
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
, p) W* e- i" a* K! F* }: f g/ T1 G+ _- D
想确定一下 [- o& ^$ d" z2 c) g9 m* ^
谢谢!" O6 C k/ \4 [2 q
|
|