|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序1 e9 n+ l% z$ W7 G
其中有一段如下
1 n3 ~) q& m! a& ^6 p) s+ \ask turtles with [ infected? = true ] 2 H1 S! z9 _$ A( W: Z8 z) z; c
我原本以为这句会回传『所有』infected? = true 的 turtle
8 H! m+ u' w" K& D$ ?( `但看结果似乎不是这样。
' t# L1 y3 R/ v2 }! H3 f3 ~; |
4 \4 f8 O: n/ P4 x# m4 R假设所有符合条件的有 5 笔9 P0 N; P- t0 j% T$ G- U
有时候回传 1 笔,有时回传 3 笔,是不固定的 E: k. O' i0 A% v) @- z
回头查语法定义/ {* d3 ~, f3 {4 F7 w$ i5 x! Z
with 1 j# R7 G, E1 t% F( e! m1 E
agentset with [reporter]
7 U7 T# C& R# W; T' D5 iTakes 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.
" l: d5 v5 F+ I+ F9 V9 ?它只说回传 agents satisfying the given condition
5 U" D) m1 \$ i2 \" N! E6 K$ g是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
# p" N9 p" \! N2 v$ k& w
2 z5 q# E7 v9 H3 _想确定一下
$ L9 k5 |8 K5 }9 T# f0 S谢谢!' \0 {) K$ _8 b
|
|