|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
( F; j, Z5 Y' K8 Y2 }其中有一段如下9 B, H( A. h2 S: l) g; v
ask turtles with [ infected? = true ]
& g+ d( Z5 _1 J. ?8 x我原本以为这句会回传『所有』infected? = true 的 turtle5 j6 [/ ^/ |4 Q" z% A ?1 [
但看结果似乎不是这样。
0 l5 R* |* s1 U$ f8 z# Q# f% N1 |& e2 M
假设所有符合条件的有 5 笔1 U5 }5 D7 w2 o6 `& s; [
有时候回传 1 笔,有时回传 3 笔,是不固定的2 \' X. d, G% [5 K$ K: y1 a( H. N
回头查语法定义8 D3 a2 p7 _ H: O
with ( }3 x0 v- k, J, Y2 B. y6 e0 q+ l( `
agentset with [reporter]
|! g. q$ C' I& q9 YTakes 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.3 l" y5 ?& d7 a3 b R% j$ o7 M) V
它只说回传 agents satisfying the given condition
# w- M6 @* c0 }是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 4 z2 Y6 q, e9 F1 F
" V& {6 l4 Y7 h, h; ]: ^
想确定一下: F1 t4 o$ v) h$ G) O4 r \
谢谢!6 n4 c) `$ B% I F6 M& }
|
|