|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序1 H" V4 M& x% d5 [, V( d
其中有一段如下) L L8 n* Y( G; D% ]5 F9 `& \6 X. d
ask turtles with [ infected? = true ]
) Y5 b; |4 S% ]0 }( x. N我原本以为这句会回传『所有』infected? = true 的 turtle
, c$ o4 g- h7 ?0 n8 l) x2 ^但看结果似乎不是这样。
6 }; y! P2 A4 d$ [1 E
. N' C8 x- h: ?; U0 c6 b假设所有符合条件的有 5 笔
7 f, y$ }; A" v: J& D有时候回传 1 笔,有时回传 3 笔,是不固定的0 m- K1 ]; y( p' u7 u. c
回头查语法定义6 ~! i, g1 Z9 W% m& g/ v/ ]
with
$ T, p" o+ G0 p; H% U( {/ lagentset with [reporter]
# ^. H2 d# X3 C6 C' j9 Y! r4 y& z1 ~Takes 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.9 B% z, Q5 Q; t% v
它只说回传 agents satisfying the given condition% @0 ^' [" {0 b! D5 b3 n+ Y
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
- v* n# M9 F( C7 H+ L3 T
1 I& f7 {. O% M# F' z+ C+ A" |想确定一下0 G+ s9 ^1 Z/ y2 l( o1 m6 z
谢谢!
. U) `2 ^3 k7 t2 A7 F |
|