|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序0 A6 F. N. f2 {: B( V
其中有一段如下 O; Q/ g: C8 n2 g
ask turtles with [ infected? = true ]
! N- \7 f, h7 A9 q+ W7 M! e* x L" u我原本以为这句会回传『所有』infected? = true 的 turtle
! t5 ?- R7 N% c4 W2 p但看结果似乎不是这样。
: {: r" S' Q/ {6 }
4 X9 i5 q5 y$ w9 n2 R# g; D4 h假设所有符合条件的有 5 笔
: Z4 Y- N0 q) L有时候回传 1 笔,有时回传 3 笔,是不固定的
/ O( I0 ]/ u: A& A5 ?6 \, B回头查语法定义
! e N2 i1 k4 o5 a) ?* Kwith
2 T3 v# r5 ~2 R- i5 ^9 o' ^agentset with [reporter]
4 B! i2 Q/ Q9 y* K. ATakes 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 P- Y8 p0 p+ f; C+ g7 P2 j
它只说回传 agents satisfying the given condition
! \( w8 y- }& H9 p% S$ Y是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? ! r+ Q1 _. F( i$ O( M
& V" L- O! [# }( f; c想确定一下
* M" C7 C) ?2 T" h5 w1 M+ X0 l谢谢!
9 G: C7 v1 O: H& @+ z3 N |
|