|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
+ _- J0 Y) R4 I/ T其中有一段如下/ x$ q- z7 M, ?. j, O3 c& R4 ?
ask turtles with [ infected? = true ]
/ u0 w8 R5 w5 S8 @# w我原本以为这句会回传『所有』infected? = true 的 turtle
, [/ \/ } n' K6 ~# m4 Q) u- t但看结果似乎不是这样。
. ]6 V1 P9 W& w) h" {& E, y) T6 G2 L" D! R. J% o5 f) ^( W2 J! |
假设所有符合条件的有 5 笔
l1 H! q* ~1 N+ a5 p有时候回传 1 笔,有时回传 3 笔,是不固定的" ]* z3 r; w" D+ U
回头查语法定义
8 K- d& v- S" z6 M4 jwith
$ F ~* W- v: {. J4 ~agentset with [reporter]( C" u0 a! \ o+ ]
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.* S0 m; Z9 R; C8 S
它只说回传 agents satisfying the given condition" {/ s/ `% t. {' Q7 g3 d+ M- G! q
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
% O) a1 q# Z A+ J! F% }# a0 J! b% x) W; ?; Q! N9 q3 d
想确定一下
8 m+ U1 \0 R+ S+ v/ R; |谢谢!
9 B2 C& V- X0 Q" p8 I8 \4 v& Z |
|