|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
9 X. C5 C! v% M$ H. K, s6 v其中有一段如下* W3 G5 W8 S! \' J( d* w3 S
ask turtles with [ infected? = true ]
) r8 ?% h- C/ C* F% D) D我原本以为这句会回传『所有』infected? = true 的 turtle
$ B; t: T, f f6 S) l但看结果似乎不是这样。5 R( k* w9 ^3 Y+ \% Y+ b2 j
. C! r2 @1 \5 M9 @
假设所有符合条件的有 5 笔- h4 l( |5 A; Q- h
有时候回传 1 笔,有时回传 3 笔,是不固定的
0 Y% V# x7 B7 R回头查语法定义
7 d5 u5 D: y; ~2 c. d* Kwith
/ n s; O V$ O- l2 [agentset with [reporter]% b9 ?! w' J$ i' Z3 N0 S1 M
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.
2 h9 f- ~6 z! M% I! T它只说回传 agents satisfying the given condition" a' F/ {6 w) ~3 X x- J
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? & H( p5 \$ |) }+ C! b+ B
[) K, v/ W7 T% q& o+ O E3 E
想确定一下 w0 G! i0 b: z2 M7 E: s
谢谢!9 u1 z5 }3 G/ \/ ~/ p$ y. y
|
|