|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序. K, R5 `% B, L: ^, g
其中有一段如下, ^: m2 d i2 K% n% D1 j) Z
ask turtles with [ infected? = true ] 8 G5 s7 `) G2 T% ?9 g" {* W+ ?. [
我原本以为这句会回传『所有』infected? = true 的 turtle# ]( O, @3 T% t! P
但看结果似乎不是这样。
, o w* K: p8 f N
/ `4 y8 P+ q9 `. n1 v$ d假设所有符合条件的有 5 笔
% |7 H8 B3 C. g' M& ]" r有时候回传 1 笔,有时回传 3 笔,是不固定的
# D) q0 J. d6 B% v" p6 L回头查语法定义
: f! j$ i! r8 B( i8 {; Kwith 6 h; X- x, s. u
agentset with [reporter]! r" }. d. w9 P; x# q% `0 M8 I0 c% T
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.
! t% j5 f+ R5 `6 ]3 E# R) w它只说回传 agents satisfying the given condition
5 q$ S# |9 R3 d- O3 l是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? - W+ u1 Z! Q& g/ I: R
7 a# C' e1 O4 z: d! M0 O0 g" S) t想确定一下( d& ~7 b1 k# b- v/ i6 v+ U, A0 S7 H
谢谢!
3 q: J! C3 }# M& Q2 G% J8 r |
|