|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序) N; P- L" `0 y" o% a$ H! p- n
其中有一段如下( A# _' w- W' ]8 M9 ]
ask turtles with [ infected? = true ]
8 a1 _3 Z: }6 p- u& t; p/ ]我原本以为这句会回传『所有』infected? = true 的 turtle
6 E: B, w% W) D) H但看结果似乎不是这样。2 { e* [+ t, D! d; C: a/ N& R
" P! L& e/ R3 a: j" |" J3 {3 E假设所有符合条件的有 5 笔5 g! p% T3 [- {. Y- g! u' j5 ]& H0 h2 e
有时候回传 1 笔,有时回传 3 笔,是不固定的( S" k, Z* P; q3 T1 |0 i% n
回头查语法定义' |% W2 {: a/ p. H, a5 t Z
with
; ~) [: N* ~# `6 P6 k( zagentset with [reporter]+ ]- F% Z8 n* E7 \
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.$ m( Q; j4 y: @
它只说回传 agents satisfying the given condition7 I2 y h F& H$ w* g3 p O, Z7 H4 X
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
! r: V( ]! u+ a( z
# p) B5 ]! ^+ {! u8 h( z, g. d想确定一下
( l" {6 W6 O k: w3 J0 `谢谢!
+ b/ w a1 K5 S# v1 O2 A5 J |
|