|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
5 j* f, U+ t+ m其中有一段如下7 a) `1 A4 q$ i+ m
ask turtles with [ infected? = true ] 8 [/ }$ Y. ]5 l" X
我原本以为这句会回传『所有』infected? = true 的 turtle
- z" d/ J+ Y* D$ P2 o% W但看结果似乎不是这样。& ?( i+ T/ K: u1 U* _8 E, D
8 [4 |! ^8 i _- A* Z; y# `3 K假设所有符合条件的有 5 笔 v- ?; V# s, @# h3 s/ }
有时候回传 1 笔,有时回传 3 笔,是不固定的; V7 X. W# _. d4 q! w5 K
回头查语法定义' I: b/ q" k7 b! F4 z# W3 H: U! s
with
4 {4 Y2 @0 C1 E% o3 }! }agentset with [reporter]
( L: x+ t& Z R( @- S! ]8 |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.
: G3 ?; C! I, N o它只说回传 agents satisfying the given condition* ^1 T! R+ E- T* S- ^
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? ) J" x/ w( l( {
+ Z0 H3 @# a F0 b* z
想确定一下
2 n6 S6 X) S2 ]6 k谢谢!, W1 L% G+ R3 x# r) f4 r! D+ E
|
|