|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序8 W$ J' k& L1 L1 P& W
其中有一段如下# j$ y& d4 B+ ~8 H+ P+ {
ask turtles with [ infected? = true ] + w- F" l ^' u" r! s) B
我原本以为这句会回传『所有』infected? = true 的 turtle
, q1 r5 ?" O) o8 Z) }% @8 l但看结果似乎不是这样。* X" ]3 v+ B. ?
* M. L/ c" y2 E5 E" O
假设所有符合条件的有 5 笔: F; h8 y1 m. l `3 [. ~
有时候回传 1 笔,有时回传 3 笔,是不固定的: ]5 f# R" } X' |9 p" Z
回头查语法定义
% l) P1 U' N/ [% Q# Q1 s4 Hwith 3 t \* |% K9 |7 W" b
agentset with [reporter]
7 X; C% Z# x1 V3 M8 ^3 j) C3 ]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.3 _; y k4 r" K
它只说回传 agents satisfying the given condition7 `1 D: y% [ D) S
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 7 x1 g& d4 u6 z5 S& V6 I6 q! i5 \
- d6 c% g4 C, |. @. ]想确定一下
7 h9 Q4 ~' R) c谢谢!9 O3 @, B3 R: W+ I) R7 M
|
|