|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序* V# u2 s9 y4 m# M: }% p
其中有一段如下 ]; I0 r3 f5 D0 P# K
ask turtles with [ infected? = true ] 7 _6 Q P+ R$ l
我原本以为这句会回传『所有』infected? = true 的 turtle5 {8 F* m% m4 i E. S
但看结果似乎不是这样。: B$ A7 @) M( }2 }& m& X5 g; d
4 j4 ~' ]3 U; W
假设所有符合条件的有 5 笔/ R/ j5 K- @; T8 S
有时候回传 1 笔,有时回传 3 笔,是不固定的6 K" ?. O% o$ h0 y
回头查语法定义
0 _8 }! d ^9 y1 N) O; k b9 D* _5 Nwith
! g5 B( `9 h, k) ~; a/ N1 `; |9 oagentset with [reporter]
) e* f3 ]4 y) bTakes 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.; J* h) j. B4 [7 l7 w+ X
它只说回传 agents satisfying the given condition
1 {! a) M/ v5 N1 @; O, b U是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 4 H# ~2 K) U4 l
& v9 p8 K- s" I2 e8 ]2 E* t# ]
想确定一下
8 m& E4 y: D+ ]# ]$ q! E& v$ ?7 s+ \谢谢!
# ?, k! S8 `" ?5 x/ N4 y |
|