|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序9 z/ k8 }0 w8 Q! d
其中有一段如下' j+ N6 o) L7 S7 R+ A; Q
ask turtles with [ infected? = true ]
8 k. F$ @3 L0 k# x2 W我原本以为这句会回传『所有』infected? = true 的 turtle
) F' ~0 m, h* D' p; o但看结果似乎不是这样。
2 Y9 c2 H4 g% Q t V
8 M8 j3 F' {4 i6 J假设所有符合条件的有 5 笔
: k( i3 C; x" o( Z6 d M有时候回传 1 笔,有时回传 3 笔,是不固定的
/ Y( M: @! n4 S) |回头查语法定义* @# T9 y _. l/ C' c
with
9 H% v. |6 X, k+ o* Nagentset with [reporter]8 a' H) X- q" j1 H) b
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.
5 ] h6 ]) C$ b. U/ w( T它只说回传 agents satisfying the given condition' M! q! }9 i$ x/ N* L5 @
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 4 c1 z: ~* j' t% G, S
; F) V7 X2 g0 a0 [* `% D想确定一下
) Q) S6 E" w q, ]8 t谢谢!4 n# B1 |; w, }3 L! M7 o
|
|