|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序7 f5 v5 c: H4 v2 z3 q! M
其中有一段如下/ t2 z" K3 f u p( c" E0 t- G: g2 U! F
ask turtles with [ infected? = true ] ' d" Y4 P/ e3 Q+ d. d! N' j# r
我原本以为这句会回传『所有』infected? = true 的 turtle' f' m# P! v6 `. A+ ^. K; c; v
但看结果似乎不是这样。
- V: Z: H8 J$ F$ O. Y3 k+ F% j! D( H+ j: {$ e+ o
假设所有符合条件的有 5 笔
) @6 C$ C. }0 b+ ]' u! }有时候回传 1 笔,有时回传 3 笔,是不固定的
1 X- p& z+ Z( E3 l5 s% ^回头查语法定义
% |% x0 x" {) _$ o0 } q6 Y% iwith ; _5 p" j% Z8 a' `' N6 f' |
agentset with [reporter]
; h8 g, ~7 P9 |$ `' I) P: eTakes 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.6 k2 k9 |: C/ E5 n
它只说回传 agents satisfying the given condition4 z" p; `2 K3 S5 \+ i. p
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
7 ~% V, r j5 b! g, b
0 e3 G' B6 u1 B n' j; s) p想确定一下 Z9 Q* @1 q8 K p
谢谢!
( j4 ~! X8 f9 p- T W8 Y |
|