|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
h. r0 f4 I- x( `# r' o; r8 B2 x" F; ~其中有一段如下' Z% o# c8 W \3 A
ask turtles with [ infected? = true ] ( R' ?8 e( d/ U' _# R; w) d& T
我原本以为这句会回传『所有』infected? = true 的 turtle
1 G E' X3 ]/ N9 T) S; S) w但看结果似乎不是这样。
) a! G- _) o: K/ Q: q" `9 K* p) G5 y: y7 D- Q0 |
假设所有符合条件的有 5 笔
; `# t8 [; N: g6 v- R有时候回传 1 笔,有时回传 3 笔,是不固定的6 L4 Q, A, ~+ f! `! C' l9 t+ T
回头查语法定义# _7 a4 y( e0 n4 L
with 4 L- v5 z0 a' t
agentset with [reporter]( z8 G& E, q9 C0 a! {1 v0 R2 o! q
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 J' T; i. M! p- J( X1 h9 y
它只说回传 agents satisfying the given condition
) x( L( `4 t; e: R+ N是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? : t- x4 h: z) L% z) k
7 z8 @& N2 t: B- ?* }+ B想确定一下
, \ g7 r( O, D! k5 P谢谢!
3 S4 s; B D4 B' \ |
|