|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
+ B9 q z0 D% M: z0 A其中有一段如下. `2 z5 o+ O- U- i: x4 B
ask turtles with [ infected? = true ]
: b. x9 @) |7 \# J) s9 X- l我原本以为这句会回传『所有』infected? = true 的 turtle
; \" K% _5 b- r$ h" \+ S9 R但看结果似乎不是这样。
4 T) a, T" S) j3 X
( m2 q( Y2 y/ Y% S) ^假设所有符合条件的有 5 笔
7 r* n+ x) w. c$ w$ b- `有时候回传 1 笔,有时回传 3 笔,是不固定的+ |+ W0 b; S# `0 @. X% G V6 N
回头查语法定义5 e5 ^8 Q7 y) g
with . v( r+ u* b, ] E' C9 t j' J
agentset with [reporter]
" h0 K# b' M5 ~) @: XTakes 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.
5 C( u }6 }) b' y& A) k7 R5 x它只说回传 agents satisfying the given condition
8 m6 I; y1 B. F( d; j% w5 i; h是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? % j; O0 ~& E1 {6 C; ?8 n
: `" a! G @, d! W# p! P
想确定一下' K8 C5 [+ |: l; ]+ G+ |9 i4 E3 H
谢谢!
: G5 D% L/ A6 c" G! K0 H |
|