|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序8 g8 H# M; w2 B% J" ?
其中有一段如下* S7 }) Z/ B8 z7 z5 Q2 }% S' Q! O/ d
ask turtles with [ infected? = true ] ' X2 T6 m3 g+ v/ d5 g
我原本以为这句会回传『所有』infected? = true 的 turtle" Y C& t0 o5 A, O: U# |! O* O4 I7 g
但看结果似乎不是这样。
- ~) f, M: w" Y' u/ x$ @
6 B3 C" ~% E) H; {( _假设所有符合条件的有 5 笔
/ X& g( o/ W6 }! f4 H9 G' [有时候回传 1 笔,有时回传 3 笔,是不固定的
3 P0 o! k; y6 u2 W+ k; w$ a) [+ V; {2 i回头查语法定义" } c, E5 S& v- e) a1 h0 p4 u6 _
with ; N- t8 T, n D& H4 W
agentset with [reporter]& r4 k% l2 X; ~8 T# x& ^
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./ J$ @$ |- G+ }. q0 Y' X9 G/ Q
它只说回传 agents satisfying the given condition: ]% G+ O: r- ~, k; e
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? ( l# D0 q3 a; T0 L" P7 G& [ Q
/ m, R/ \, o D& X% c想确定一下) Z/ f. u! R3 q8 i; s
谢谢!
7 y& Y1 L6 K3 y |
|