|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序# U9 v8 k5 L- N
其中有一段如下8 k3 Y( J( ]$ h* \) H; ~
ask turtles with [ infected? = true ] {8 _) f# u! \4 N: H
我原本以为这句会回传『所有』infected? = true 的 turtle
& g9 l1 R( S6 b% r9 q# v' \但看结果似乎不是这样。
9 n* T& E3 t8 x+ C9 ]6 g& U* u
假设所有符合条件的有 5 笔% B* q* V, ^( q4 |
有时候回传 1 笔,有时回传 3 笔,是不固定的
% d* @1 [+ W4 m% I+ Q9 P, y回头查语法定义* E3 ^6 O* f! x% F" U. m, J8 {
with
. C" ?/ d6 p/ w3 z# R9 Yagentset with [reporter], n; f `- Y+ i: S
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.
6 I6 b& C0 @9 q+ C它只说回传 agents satisfying the given condition) S! D4 w8 A7 h0 h9 ]' V
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 4 }8 y6 N9 z# x! g" P2 G
/ ^7 }% I/ @" V r$ m- |
想确定一下
. `( z f- K$ ~* \# L, t谢谢!- A P3 C- }2 M3 S4 M0 L
|
|