|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序3 R0 n( [6 `# z& E t9 x3 g
其中有一段如下# o. t" g. J; y$ {
ask turtles with [ infected? = true ] & r# _+ o8 f# A, r0 x
我原本以为这句会回传『所有』infected? = true 的 turtle6 j2 G" f) ~1 C) H$ H$ L( ]- Y9 [
但看结果似乎不是这样。. j2 N8 ^ {- t( `& X' @ S. }
) e2 `" ?2 w" r5 S# w4 D. h假设所有符合条件的有 5 笔" Y. b; ^8 {6 W$ A3 F
有时候回传 1 笔,有时回传 3 笔,是不固定的- J/ q" o2 N" s8 H' E- P, c3 c4 u
回头查语法定义' K7 l6 @& p( U
with 4 h# p. {/ p* ^; R4 g
agentset with [reporter] O) d0 f3 g" z& @6 n4 _
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.
4 l: u* L4 A* }: S0 G它只说回传 agents satisfying the given condition1 q+ `# g$ U% k6 m+ ?" ]& s) k
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 2 c" z$ A- |# N
: k! W, a* c, p
想确定一下
% B2 V% x2 }0 K1 ]# \) S4 S谢谢!# W/ N/ s4 K, N3 S, ]2 R
|
|