|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序( E$ B( U! P$ s* a& h# O: b
其中有一段如下3 e* g# z5 Y7 ` S
ask turtles with [ infected? = true ] - {5 H: D, M( ]1 |
我原本以为这句会回传『所有』infected? = true 的 turtle# `& ]2 e0 S7 l
但看结果似乎不是这样。
; B A# j% |- E3 G2 q3 S2 X3 I6 L" l
- V3 n: \" |0 G4 r假设所有符合条件的有 5 笔
: W! l8 }" b3 s6 y9 n有时候回传 1 笔,有时回传 3 笔,是不固定的
8 ]5 d2 P# [2 z: w9 L回头查语法定义9 B- U4 a" f: x h/ B( H. m
with % T# {/ O5 y0 t/ C: b: [% u
agentset with [reporter]
) G& _8 @8 p% \$ Y# |7 a9 N% N; bTakes 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 @. b7 i* s+ L' G6 d# e它只说回传 agents satisfying the given condition
6 [* [4 H9 |% \5 ]+ t1 r! ~是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
( q2 }, U4 V- [# q8 H- H1 J& c
( e2 F+ Z5 u$ n# }想确定一下
* g) t# p, [; H# z* u谢谢!
9 g$ A: i6 ~% e# r" J, ` |
|