|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
) ~' O4 X" N* m& K D) g其中有一段如下
( z. G3 q) B# W+ D( x$ u7 l& ^ask turtles with [ infected? = true ]
2 j% H$ }9 f% Q" Z% S8 Q我原本以为这句会回传『所有』infected? = true 的 turtle7 x- C3 M9 T' V" f5 D5 A
但看结果似乎不是这样。) b% q% K3 ~* f$ ~
. _6 R) C4 O* q+ _4 P1 C6 e
假设所有符合条件的有 5 笔9 D: O a+ R- k& y: D5 r0 ]
有时候回传 1 笔,有时回传 3 笔,是不固定的
$ ?* {6 h N' I- v2 ^回头查语法定义
. j" f! F2 A9 f# z$ [with
$ u, w1 s+ z- {( C( I$ Oagentset with [reporter]
" x) e4 L" f6 f2 pTakes 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.
. _2 F w4 i. H/ s它只说回传 agents satisfying the given condition
, R$ ]& `9 d- e p5 A5 [- P是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 7 s& H. W& [& ]. x, K. v7 u
- |3 F" g# B5 y; D% F想确定一下) c: R' {+ L3 K0 ^* D d
谢谢!( i1 g/ y3 h3 e8 B6 d2 T
|
|