|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
3 W! @- x/ z+ R. e4 o: w* i其中有一段如下4 e" F$ f6 T# t. }8 V
ask turtles with [ infected? = true ] ; @* ~8 t/ V& M- P0 C. N- |1 p
我原本以为这句会回传『所有』infected? = true 的 turtle' w4 ~. {; I7 j" Q' S
但看结果似乎不是这样。
0 a9 ~- W" q" }& b1 y a# R% Q( x( X7 X4 |/ B1 Q
假设所有符合条件的有 5 笔( e8 c/ f' g2 {% N+ L
有时候回传 1 笔,有时回传 3 笔,是不固定的+ Q- r! W7 p) d4 N* z- [' _
回头查语法定义# @0 @! W$ |+ b) M
with
: X, N7 z2 v: t5 ?% A, ~' Sagentset with [reporter]5 j5 a. n& a2 g g+ y! t
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.
/ M2 R5 B. v! p8 K5 Z5 `它只说回传 agents satisfying the given condition, b. O$ [- O# D
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 6 O8 d. M' I9 r* S+ U, K$ K4 @8 Q
' e- [1 n) q+ {想确定一下$ h) b5 u, |' F8 G6 k8 F$ G: Q
谢谢!
) B$ L! r# n" I |
|