|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序( \$ K6 ~* A) S; K4 y6 F0 c3 U
其中有一段如下! Z: G; F# \5 ~5 ?2 y ?
ask turtles with [ infected? = true ]
, N$ k$ c, P3 F) o0 X4 _+ R6 Y我原本以为这句会回传『所有』infected? = true 的 turtle
8 I; `6 w- ?; e/ L但看结果似乎不是这样。$ @/ ?% s S- j0 H8 A- J' Q# ]- e' l
$ W" m, H; _# E. J) P8 V5 t
假设所有符合条件的有 5 笔( a( r5 J4 S3 M: G1 S' J; w) Y* Q
有时候回传 1 笔,有时回传 3 笔,是不固定的0 B7 `6 w' K) @3 a
回头查语法定义2 q8 k3 f; s' ~* ^
with . X( g& X1 @8 C1 g5 G* t( @- T( v
agentset with [reporter]
+ b$ w, d2 p9 z! S0 F) t5 tTakes 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.
! m4 d9 ~5 i5 r它只说回传 agents satisfying the given condition& w1 d8 @. q. M8 C
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
; c, S7 B% p- T, u5 H- j! j
3 r- d( J+ x" C. c想确定一下7 z7 D: u# [: r" ~, r* F- f
谢谢!
( f4 ?; o9 r" m9 _: R+ s) n |
|