|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序! Z q+ L/ l! a2 `; b* x7 N
其中有一段如下+ o3 B t1 E% S6 C1 w; ], c
ask turtles with [ infected? = true ]
8 v* a( a9 G6 a我原本以为这句会回传『所有』infected? = true 的 turtle4 C3 b/ L4 C3 O( U: s+ K
但看结果似乎不是这样。
- C6 i- |9 E& Z! i; K5 F' j7 j" D! d
假设所有符合条件的有 5 笔- o) ?8 J1 A! K2 h5 m6 x
有时候回传 1 笔,有时回传 3 笔,是不固定的
6 D1 i! ? ^5 f V. ^2 n回头查语法定义
8 d) R3 a4 {& A& p5 S) Awith : L& P5 L: |4 s
agentset with [reporter]3 `4 Y0 D/ M" X& x+ u
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.
8 I1 A% @. T/ L9 I8 x' y' O它只说回传 agents satisfying the given condition. g( X1 p$ ?9 N( b7 P, Y! P$ }
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
2 | z4 L9 r3 g0 H! |& G- d f1 u, R0 W8 Y1 x1 p% p1 k
想确定一下
8 t: Y& \! @$ I3 r r) J# l F谢谢!
U' d* g) ?# ?" r/ P/ l8 g |
|