|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序% ^/ W9 r$ ^2 V4 f% I% D
其中有一段如下& s1 M* r; E3 d4 i) [, e
ask turtles with [ infected? = true ] 2 ]. c) I) ]4 \. z* U' y
我原本以为这句会回传『所有』infected? = true 的 turtle
1 G; t. v1 u& [2 |; Y0 w/ J但看结果似乎不是这样。! ?$ F' \$ ?8 l4 i
% V; F! @- B6 W/ ?$ h" b+ v假设所有符合条件的有 5 笔
& _$ ]1 ^, V' Y4 B5 R有时候回传 1 笔,有时回传 3 笔,是不固定的
0 R S- D2 u0 K) ~8 r& T回头查语法定义
5 a. _1 `6 A1 @' C; A: @with ' V* ^' G1 k0 T+ ^
agentset with [reporter]! f. u1 _1 @+ j
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.1 B3 G" @9 G2 X, n' {
它只说回传 agents satisfying the given condition$ l9 i6 _) A- `( c
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
7 O k: ?( _8 i/ m, \- W
0 s% {. B! \# B3 D- m8 G想确定一下2 r9 O+ q4 `& l, M" ]8 U$ G9 I4 p
谢谢!0 d+ f% O* `9 w
|
|