|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序/ R% {# d; `( R/ ^/ K a
其中有一段如下8 F; ?5 g* L( l9 _; q/ z
ask turtles with [ infected? = true ]
! r, u: G9 I; Y+ q/ }+ _我原本以为这句会回传『所有』infected? = true 的 turtle3 Q( i' ^; G, d2 X8 W: t- W" K' l
但看结果似乎不是这样。" N6 m8 @9 Y V9 i; o
, b# m" t v- K假设所有符合条件的有 5 笔
! a% h- v5 U5 Q$ ]: l% Q: p有时候回传 1 笔,有时回传 3 笔,是不固定的
5 P- h" a& {6 A. X' h6 s* j! u回头查语法定义! l6 _; h5 F8 k: D
with * Z) \, U2 q; F8 J7 t2 g
agentset with [reporter]+ @- z q w% q' 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.
* k' {0 l2 Q$ ^) f( `4 Y它只说回传 agents satisfying the given condition
( z {3 v% N2 N8 _ P8 P是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
% E; m6 `, c1 l! }, o) P+ T9 r' \ @/ G* o7 @& T1 J0 n
想确定一下
$ F, ^/ H/ i2 j$ J谢谢!
3 r9 {. H/ @4 v- K: S& ~9 V |
|