|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
6 p; [4 A- A7 R$ b其中有一段如下
: D+ I: R! S7 u$ a. O+ L, j! C$ `ask turtles with [ infected? = true ] * i/ @( c! ]7 q% a4 w
我原本以为这句会回传『所有』infected? = true 的 turtle9 N3 t0 U: r, Q# s/ T" J
但看结果似乎不是这样。
4 |9 d/ k L) R
$ q" d4 w- N. v! N假设所有符合条件的有 5 笔" O; Y5 R2 z* O9 m* y
有时候回传 1 笔,有时回传 3 笔,是不固定的9 R; Z# U" f, T" h3 Y0 Z% V
回头查语法定义
; N) M9 ^& c' `+ t2 C3 B; xwith
; y0 ]% j% k2 V& n5 W/ hagentset with [reporter]
5 x0 R) u) t( s- W& _% v2 c% a$ \+ wTakes 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.
; A2 w k6 e6 A& g: ]4 B3 s( l它只说回传 agents satisfying the given condition! M+ r( u8 j3 w+ Y6 A- S
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
9 x$ d( R' C. x. ]/ S# P% J
) h6 K( v& A# ~* j C. B! ^) W想确定一下( G; R: Q* [, L( T! @5 K+ F
谢谢!: d% C5 A% G/ c% I4 z8 ?- l% s5 e
|
|