|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序; @4 }/ u! |2 R, X% [) Z# q* r) M% r
其中有一段如下; A8 f& I) V* w
ask turtles with [ infected? = true ] 1 h9 ], c- c" d# X( \! x+ E
我原本以为这句会回传『所有』infected? = true 的 turtle3 X, d2 d- {0 { P
但看结果似乎不是这样。: G" y$ ?+ c x6 `- ~
9 Z- Y/ Y$ j. w& R; Y) X
假设所有符合条件的有 5 笔5 R" z! L0 q* w
有时候回传 1 笔,有时回传 3 笔,是不固定的. z3 R% d$ d, V, U$ V& f! D' V
回头查语法定义* @) ?5 x0 y2 P: T/ f
with ! D! {& y, H9 @6 H
agentset with [reporter]
) b1 ^- o% J; R- c' A# o0 XTakes 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.
# j1 V+ |( K( E8 {; Y它只说回传 agents satisfying the given condition
! q @$ Z; F, E. \' w/ H$ e1 I是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
# K9 _6 s5 c% u1 P0 }. T
0 X6 n) F, L+ m3 c% j1 u想确定一下) f5 K9 T( `* [ s9 F/ v M
谢谢!- {$ B" H n; m4 c
|
|