|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
( |! ~% b! P' _9 ]其中有一段如下8 h d- v! q2 [) _
ask turtles with [ infected? = true ] % b4 m3 N* N4 W4 p+ j$ _# o
我原本以为这句会回传『所有』infected? = true 的 turtle
+ Q* c; T7 [0 x/ H9 @) o l' f但看结果似乎不是这样。6 B* i% p* p% A! Q {# g
2 _. B: ^- R s8 S假设所有符合条件的有 5 笔7 U. M4 l; p& u) L4 P8 i
有时候回传 1 笔,有时回传 3 笔,是不固定的6 D' V8 L4 c# W, N
回头查语法定义
/ i& \# D `9 N4 Twith * S0 `$ d# F7 g# m0 Q- C# H
agentset with [reporter]
& N4 J( O9 S& NTakes 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.
& r. o x8 _+ l它只说回传 agents satisfying the given condition) f) B* ?" A' b% d* \1 v
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
* r. r4 K L2 j, z9 B- R8 B/ Y: k3 s+ n3 {3 w7 l T
想确定一下
/ }, a2 ]. H' G7 N" \; |谢谢!
! Y1 g- V3 M, V |
|