|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
; J9 L0 ~) O' N$ I其中有一段如下0 k$ g, [# ~3 k4 y
ask turtles with [ infected? = true ] 8 I" O8 M8 E1 V. j' @
我原本以为这句会回传『所有』infected? = true 的 turtle
$ O1 \) @# V$ H3 F$ _& `4 a& J但看结果似乎不是这样。
! j# G" V" f( a; X! W& f/ O4 }8 S4 q
假设所有符合条件的有 5 笔
7 ^% g5 y9 t8 h4 w$ B, Y' u有时候回传 1 笔,有时回传 3 笔,是不固定的$ F8 n' _. [0 O' `& S; Q3 ?9 z4 |& i
回头查语法定义
/ `: ~2 E& o) W x; G6 qwith $ h( X7 a! y- i8 g) n
agentset with [reporter]
! o3 K* u2 }! L& GTakes 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.% b) A: {. \$ f/ t5 R1 P8 r
它只说回传 agents satisfying the given condition% j5 h! B$ f j
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? ' l) S3 A) b: e: @% j- a4 U
8 {: O9 y. n% z想确定一下; J. W/ n( g( C1 D, i+ c: T; f
谢谢!
% R3 h5 ^7 D M) l1 \3 T |
|