|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
6 l% C0 P, Q8 v, k4 Q- A其中有一段如下7 ~5 W+ p6 D5 c A
ask turtles with [ infected? = true ] " r, k/ K" E* t4 {7 q' m$ ?
我原本以为这句会回传『所有』infected? = true 的 turtle4 g k! b% l2 h" c8 d( ^$ I! X
但看结果似乎不是这样。
8 D) Z) \. h! z- P$ n5 |" e
/ p- d) g; D9 D* @7 v! E假设所有符合条件的有 5 笔: G% e( n& d; [
有时候回传 1 笔,有时回传 3 笔,是不固定的
$ [9 }2 u* G y1 d4 u4 O+ {回头查语法定义
1 y# f0 w6 N/ H b2 B" vwith " v/ D0 g; M1 R
agentset with [reporter]
! o7 ?+ X. `; {$ \5 I O- KTakes 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.+ U( K2 Z1 L0 _$ L- t
它只说回传 agents satisfying the given condition+ s# Y3 e. d8 O: u( k* a$ l) Q
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? + F% i+ x" V C) y4 A# z* U8 o1 ^ q0 b
6 r- Q* W- E0 O$ b! p" y6 m
想确定一下
: v7 |1 f! t3 D+ Y. o/ I6 S$ e谢谢! K2 L; W; q# H( ?: T
|
|