|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
4 {; g5 g9 G0 O/ V8 c P其中有一段如下5 @5 F6 M/ x- w. p) Z) t
ask turtles with [ infected? = true ]
+ W$ ^: I* e& c9 a, T- X; [我原本以为这句会回传『所有』infected? = true 的 turtle. \; j+ j& I6 Y/ g* F' u8 K* q
但看结果似乎不是这样。% H4 d" G. P8 Z5 L! Y
7 `, h S9 r, |' F1 Z; E8 F
假设所有符合条件的有 5 笔# R8 v, p* L+ i- w: z. R5 Z
有时候回传 1 笔,有时回传 3 笔,是不固定的
' W9 ^) t4 D# g; ^回头查语法定义5 X$ E/ _6 @9 N5 I5 S
with 6 G# [! U6 B3 u% Y1 r; [4 K
agentset with [reporter]
$ m" |9 V6 V, l- u6 c: f+ dTakes 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.5 J8 M1 s8 w) ]% H! Y, c+ K: m+ ^8 o
它只说回传 agents satisfying the given condition
/ U8 e7 {, N" w% A" T) k+ t是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? ' l8 K W# W; S* X' j' K2 d2 n* ~
1 N( [5 h0 R* \# o+ u
想确定一下4 ~0 ~; O6 k$ z; p2 E
谢谢!8 r% f" `; L( F- t V/ ~5 T
|
|