|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
! O) k/ z2 Z) `# @: _: f# R其中有一段如下' c( O9 I# W6 J0 |
ask turtles with [ infected? = true ] w6 I; O" R2 z$ D$ M. f5 ^$ c) y3 |
我原本以为这句会回传『所有』infected? = true 的 turtle5 H0 j! Z# S: u' f/ a% i [
但看结果似乎不是这样。
3 g- w' k y7 G4 @3 n- e. i- U5 I" g4 e9 k- `3 z, \
假设所有符合条件的有 5 笔
8 @5 ]: E9 ^7 \+ o4 |, w6 j0 t% n有时候回传 1 笔,有时回传 3 笔,是不固定的
: w5 W7 s$ K/ a7 B2 h2 Z3 a& W回头查语法定义: r" d/ K5 U# l
with
* N; o5 J) h5 J7 n5 ^0 [ B- Bagentset with [reporter]
/ ^# a1 T$ t+ h3 R0 F- R3 I" \& eTakes 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.8 f- \/ }6 l! O" A
它只说回传 agents satisfying the given condition
4 \% e& p. I7 i2 T5 `4 ]. O& [是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
g4 e7 ]3 }' B* { L, z
+ t* K3 D- w H! ]想确定一下) H z: P7 M/ W5 E+ c4 d
谢谢!3 H. W: \% d% S
|
|