|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序9 J* e4 H8 @6 [) W
其中有一段如下4 [0 T+ X8 V5 k$ m8 R8 h
ask turtles with [ infected? = true ]
: H) g( \1 M: q' e8 o我原本以为这句会回传『所有』infected? = true 的 turtle# C: B, ~ t# p+ Q! h9 a7 p
但看结果似乎不是这样。
! J$ y! r2 l: s- X5 y
( w8 B* Z& d% c' o+ s! T2 {5 S# r假设所有符合条件的有 5 笔' m- Q% u: k. x# v ^6 q& U4 n
有时候回传 1 笔,有时回传 3 笔,是不固定的/ |/ }/ \) V4 N& a4 J* z3 A
回头查语法定义
& |# a1 |- Z5 f! S0 n/ S( Hwith
/ ~; T8 L6 n7 w+ W1 Dagentset with [reporter]% q; D! C, e o+ O; i% |% m& 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.% K; e3 I6 Z X' Q" ?& y, |0 t
它只说回传 agents satisfying the given condition5 D; Q3 c4 }% h. y
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
3 I8 w6 F% A, H7 n% S3 W& |/ _; G
想确定一下: U$ c1 {# {# j2 B- y
谢谢!7 q2 E3 h( x0 @, `! C$ Z* b$ b' d
|
|