|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
b6 e: [; M! e6 `% L5 W, _其中有一段如下: N! b, S3 D7 |7 p8 U% B
ask turtles with [ infected? = true ] / e# F0 d; [" ~- }. d6 j" }
我原本以为这句会回传『所有』infected? = true 的 turtle, s8 s- C4 d6 X5 B# J! U
但看结果似乎不是这样。) X. [8 j7 T. F( ?' k- Z h
; J( l, W7 U. |8 k& V. s5 M* p1 O
假设所有符合条件的有 5 笔" X R# P9 L8 {+ p, [1 E
有时候回传 1 笔,有时回传 3 笔,是不固定的
. T1 L: B; C, c" x+ a" Z' S1 ] {回头查语法定义; h+ X& q( t5 Z+ D/ F
with 7 I8 Z& u1 m$ ?1 R
agentset with [reporter]3 I% Y3 d3 z2 {6 x5 i
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.
7 o! T* m* F3 b ^; j( ]' J它只说回传 agents satisfying the given condition) W( \/ u7 A1 D( K; h$ K" l* ~ g2 p: Q
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
5 ?; f' K! Z; ^, x9 d. ] a0 @, e$ {6 S' }% e2 q6 [
想确定一下, i3 H: e1 s, Q
谢谢!# L8 |! g5 }/ M* u1 c L" @
|
|