|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
# D. d3 t4 K/ z% F6 \其中有一段如下
9 U6 Z% U: m' A- k9 u9 @ask turtles with [ infected? = true ] 2 B+ O, d7 p" U; _6 _
我原本以为这句会回传『所有』infected? = true 的 turtle) z! m x: }3 m
但看结果似乎不是这样。* b# Z6 ^; H: c4 I+ i$ X) v
6 m$ |, Y I% @. |( n5 V
假设所有符合条件的有 5 笔
b: s z) I6 Z, `' R7 w0 c; c有时候回传 1 笔,有时回传 3 笔,是不固定的; s) o; P j' J. x
回头查语法定义
+ |7 N; h7 l2 ~, o, }* Z: ] s; _with * w6 M; Z1 k+ q( [4 c
agentset with [reporter]
3 J4 T c5 d: KTakes 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.+ d3 ~1 u9 v" a* A$ C
它只说回传 agents satisfying the given condition0 Y' X$ _# G# q5 T: S/ ^
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
3 Y0 d, _& } K% H4 e/ Y! R
) g& z4 q5 w6 s1 o3 \+ k7 R+ s, e想确定一下
7 T+ O% V* g% T$ B. q i谢谢!3 F+ S! Q# [+ h, l' a
|
|