|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序; N" G4 q: `+ a
其中有一段如下, i J+ ]3 {3 Y: r0 l `# e
ask turtles with [ infected? = true ] $ s) s* [* r7 |4 s2 Y3 B7 a
我原本以为这句会回传『所有』infected? = true 的 turtle
( L. T7 v9 w/ l" w但看结果似乎不是这样。
% ?- H5 Z& T9 L7 d8 }& q0 Z7 G% a4 P/ z6 |- p+ t: {6 p. J9 E
假设所有符合条件的有 5 笔
" w1 C2 ?' `3 y i, t, p6 u# h有时候回传 1 笔,有时回传 3 笔,是不固定的8 B% Q& u- @8 w5 H
回头查语法定义
" F/ i& @) j# Pwith ) b) H4 v) v/ E$ g- l& C
agentset with [reporter]6 I! t; X7 {2 \* h1 q" e
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.4 B; q; t8 I; Z' O7 ?: i
它只说回传 agents satisfying the given condition9 x" y( [1 X7 j2 l6 T/ @* _
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? , N' J: `$ t0 C- t! { L- J* S
- E: k( B* [; h9 D" y
想确定一下
& N$ J& A& r3 T+ }) v谢谢!
5 W0 q$ l; u" [6 ~1 ^ |
|