|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序: {/ T4 g ?$ r, b. f8 \: y" I
其中有一段如下2 v4 J6 S- ~) \
ask turtles with [ infected? = true ] ) x/ i* T6 r6 G# Z0 W
我原本以为这句会回传『所有』infected? = true 的 turtle! K4 q6 p) Q' T3 D. K8 v& L( W
但看结果似乎不是这样。/ Z% O, A* v1 ?' w8 v1 k% Y
, M9 z$ U# F; d假设所有符合条件的有 5 笔
2 S4 m! C8 r2 L% U. l( r" _% J7 Z1 E6 x有时候回传 1 笔,有时回传 3 笔,是不固定的/ E$ E% p/ e$ _1 E# h6 d/ k
回头查语法定义
" p* v1 J- i- mwith
6 u. L: f" s O! n5 ^, {' Yagentset with [reporter]
6 }; C# M& [6 LTakes 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 g: [8 o) o! b# o9 q8 p( R; I
它只说回传 agents satisfying the given condition- j" ~" x$ y) R5 E$ `- h" z1 v
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 5 Z3 J; `* v- s" \% j- Q
& O, d% a5 V0 g$ ?6 z3 E' g$ U想确定一下
: @# \; e$ ?+ u& i谢谢!
; e/ q/ H/ a, I; T# j; ] |
|